This is one in a series of videos covering MATLAB basics. It is meant for the new MATLAB user.
This video covers how to convert two equations into matrix form and then solve them in MATLAB. This is one of the most basic problems in linear algebra. It is handled nicely in MATLAB, MATrix LABratory. This video shows how to define a small matrix and vector.
Well, that’s what I tried:
Let’s say that y=A*x
In my case, I have:
A=[gamma2(:,1),gamma3(:,1);vega2(:,1),vega3(:,1)];
y=[gamma(:,1);vega(:,1)];
x=A\y;
But with that code x has only two values, and I want x to be a vector. Do you see my problem? Thanks a lot
Hi,
I understood your video, but how to do it if the coefficients of the equations are vectors? For example, if I have:
gamma1(:,1)= nc2(:,1)*gamma2(:,1)+nc3(:,1)*gamma3(:,1)
vega1(:,1)=nc2(:,1)*vega2(:,1)+nc3(:,1)*vega3(:,1)
and I want to find nc2 and nc3?
Thanks a lot!
Sebastien,
You will want to store those coefficients into a dedicated matrix. You will have to use subscripting to get them into the matrix from those vectors.
Doug
Well, that’s what I tried:
Let’s say that y=A*x
In my case, I have:
A=[gamma2(:,1),gamma3(:,1);vega2(:,1),vega3(:,1)];
y=[gamma(:,1);vega(:,1)];
x=A\y;
But with that code x has only two values, and I want x to be a vector. Do you see my problem? Thanks a lot
What are the dimensions of A and y once they are constructed?
I suspect that they are
A = 2×2
y = 2×1
If that is the case,
x = 2×1
That is expected.
Doug