How to show a equation?

7 views (last 30 days)
Hi MATLAB Community,
I Would to show a equation in the follow expression :
T = a1*f1+a2*f2+a3*f3+...+an*fn.
The vector there are all coeficient (a) and also the matriz (f), (depend of result the code previously).
I would to have a idea, how to build a structure, for take the value present in vector (a) and matriz (f), and show the equation example before. (The quantity of element can be different).
%Example:
a = [ 1 2 3] %vector of coefficient (in this case n=3)
T = 1.*F1+2*F2+3*F3; % Equation built
Could help me?
Thank you.
Guilherme

Accepted Answer

John D'Errico
John D'Errico on 24 Feb 2019
X = sym('X',[1,3]);
coeff = rand(1,3);
vpa(sum(X.*coeff),5)
ans =
0.022414*X1 + 0.053832*X2 + 0.14087*X3
  1 Comment
Afifah Shabrina
Afifah Shabrina on 3 Nov 2020
clc;
clear all;
data = load('hypodd.reloc');
x = data(:,3); %Bujur
y = data(:,2); %Lintang
z = data(:,4); %Kedalaman Gempa
A = [x y ones(length(x),1)];
[cc,bint,r,rint,stats]= regress(z,A);
% PLOT PEMODELAN
scatter3(x,y,z);
hold on;
x_grid=119:0.05:120;
y_grid=-3.2:0.05:-2.2;
[XFIT, YFIT]=meshgrid(x_grid, y_grid);
AFIT=cc(1)*XFIT+cc(2)*YFIT+cc(3);
surf(XFIT,YFIT,AFIT);
set(gca,'ZDir','rev')
% LABEL
title('\fontsize{14}Model Bidang Sesar Bedasarkan Hiposenter Gempa');
legend('Hiposenter',1);
xlabel('Longitude')
ylabel('Latitude')
zlabel('Depth in Kilometers')
Hello, can you help me to show the equation of AFIT=cc(1)*XFIT+cc(2)*YFIT+cc(3) this?

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!