MATLAB: Getting a wrong solution to a simple linear system using “solve”

solve

I am trying to solve the following simple symbolic singular 6X6 linear system using "solve":
[xx,yy,zz,yz,xz,xy]=solve(' 0*xx -f1*yy + f1*zz + (b1-c1)*yz + d1*xz -e1*xy=0' , 'e1*xx -e1*zz -d1*yz + (c1-a1)*xz + f1*xy=0' , '-d1*xx + d1*yy + e1*yz -f1*xz + (a1-b1)*xy=0'… ,' -f2*yy + f2*zz + (b2-c2)*yz + d2*xz -e2*xy=0' , 'e2*xx -e2*zz -d2*yz + (c2-a2)*xz + f2*xy=0' , '-d2*xx + d2*yy + e2*yz -f2*xz + (a2-b2)*xy=0' )
The correct answer should be xy=yz=xz=0 and xx=yy=zz=z (z free parameter). Instead I am getting xx=yz=xz=z and xy=yy=zz=0.
Why is that?
Also, is there a way to solve symbolicallty using matrices? Something like linsolve with symbolic arguments?
Thanks Uri

Best Answer

Hi Uri,
this is because you are using a wrong syntax for your problem. With the following syntax everything works fine
sol =solve(' 0*xx -f1*yy + f1*zz + (b1-c1)*yz + d1*xz -e1*xy=0' , 'e1*xx -e1*zz -d1*yz + (c1-a1)*xz + f1*xy=0' , '-d1*xx + d1*yy + e1*yz -f1*xz + (a1-b1)*xy=0'...
,' -f2*yy + f2*zz + (b2-c2)*yz + d2*xz -e2*xy=0' , 'e2*xx -e2*zz -d2*yz + (c2-a2)*xz + f2*xy=0' , '-d2*xx + d2*yy + e2*yz -f2*xz + (a2-b2)*xy=0' );
xx = sol.xx
yy = sol.yy
zz = sol.zz
xy = sol.xy
yz = sol.yz
xz = sol.xz
This behavior is also stated in the documentation:
For a system of equations and an equal number of outputs, the results are sorted alphabetically and assigned to the outputs.
I hope I could help,
Friedrich