How to solve this multi equation using matlab program
Show older comments
I have this ,
syms p1 p2 p3
pi =[p1 p2 p3];
and this equation,
y=[-2*p1 + 2*p2 , -1*p2 + 1*p3, 3/2*p1+3/2*p2-3*p3]
[A,Z]=equationsToMatrix(y,pi)
so i get matrix A,
matrix A must fulfill this equation to get pi unique, that is d
d=p1+p2+p3==1
[B,Y]=equationsToMatrix(d,pi)
after that, i dont know how to get pi value
if i calculate manually, i must get p1=3/19 ;p2=12/19 ;p3=4/19 ---> the sum of pi=1 that is the same as d
if i dont use d, the value of pi all equal to zero.
i already use this,
sol = lsqlin(double(A),double(Z),[],[],double(B),double(Y))
sum(sol)
i got this,
sol =
0.333333333333333
0.333333333333333
0.333333333333333
ans =
1
the sum of sol(that is pi) equal to 1, but the pi is not same as i calculate manually.
Accepted Answer
More Answers (1)
According to your y-vector, you want to have
-2*p1 + 2*p2 = 0
-1*p2 + 1*p3 = 0
3/2*p1+3/2*p2-3*p3 = 0
Insert
p1 = p2 = p3 = 1/3
and your solution
p1=3/19 p2=12/19 p3=4/19
and check which one is correct.
syms p1 p2 p3
pi =[p1 p2 p3];
y=[-2*p1 + 2*p2==0 , -1*p2 + 1*p3==0, 3/2*p1+3/2*p2-3*p3==0,p1+p2+p3==1];
[A,Z]=equationsToMatrix(y,pi)
sol = A\Z
Categories
Find more on Linear Least Squares 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!





