Matrix calculus and solving system of equations
Show older comments
I have a Aleator.xlsx table from I imported the integer value in D => and construct a matrix in the first column we write the difference
DM(i,1) = D(i,1)-D(i+1,1); .... DM(i,10) = D(i,10)-D(i+1,10); and b1= D(1027,1).. b10= D(1017,1);
I have to calculus the coeficents a11, ...a10,1 from equations
b1 = DM(1,1)*a11+DM(1,2)*a21+DM(1,3)*a31+DM(1,4)*a41+DM(1,5)*a51+DM(1,6)*a61+DM(1,7)*a71+DM(1,8)*a81+DM(1,9)*a91+DM(1,10)*a101;
b10 = DM(10,1)*a11+DM(10,2)*a21+DM(10,3)*a31+DM(10,4)*a41+DM(10,5)*a51+DM(10,6)*a61+DM(10,7)*a71+DM(10,8)*a81+DM(10,9)*a91+DM(10,10)*a101;
And write the result in Vector Rez = [a11 a21 ... a101];
Please Help!
Accepted Answer
More Answers (1)
Dheeraj
on 3 Sep 2024
Hi Viorel-Mihai Popescu,
You can use "xlsread" function to read to the file and the data associated with it. you need to set up a system of linear equations based on the provided matrix equations and solve for the coefficients
. Below is an example to do the same assuming you have "DM" matrix created using your logic.
Formulate the system of equations
% We need to solve DM * a = b
% DM is (nRows - 1) x nCols matrix
% b is a column vector of size nCols
% Check if we have enough equations and variables
if size(DM, 1) < nCols
error('Insufficient number of equations.');
end
% Solve for coefficients a
% We are solving DM * a = b
% Using left division to find a
a = DM \ b;
Thank You.
3 Comments
Viorel-Mihai Popescu
on 3 Sep 2024
Moved: Torsten
on 3 Sep 2024
Torsten
on 3 Sep 2024
Insert the lines
size(DM)
size(b)
before using the command
a = DM \ b;
What does MATLAB print out for the two sizes ?
Viorel-Mihai Popescu
on 3 Sep 2024
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!