How to show a equation?

조회 수: 7 (최근 30일)
Guilherme Lopes de Campos
Guilherme Lopes de Campos 2019년 2월 24일
댓글: Afifah Shabrina 2020년 11월 3일
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