How to show a equation?

7 次查看(过去 30 天)
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

采纳的回答

John D'Errico
John D'Errico 2019-2-24
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 个评论
Afifah Shabrina
Afifah Shabrina 2020-11-3
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?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by