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

 Réponse acceptée

John D'Errico
John D'Errico le 24 Fév 2019

0 votes

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 commentaire

Afifah Shabrina
Afifah Shabrina le 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?

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by