getting a wrong solution to a simple linear system using "solve"
Show older comments
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
Accepted Answer
More Answers (1)
Friedrich
on 1 Apr 2011
I think that MATLAB gues the right values is a little bit luck. Normally you would specify what you want to solve:
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','yy','zz','xy','yz','xz');
xx = sol.xx
yy = sol.yy
zz = sol.zz
xy = sol.xy
yz = sol.yz
xz = sol.xz
I think you can pass a matrix to solve. This works for me:
>> syms a b c d
>> A = [a b ; c d],
>> sol = solve(A)
Friedrich
2 Comments
uri albocher
on 1 Apr 2011
Friedrich
on 1 Apr 2011
Yes i tried it and it works fine:
syms a b c d
A = [a b ; c d],
sol = solve(A)
A =
[ a, b]
[ c, d]
sol =
a: [1x1 sym]
b: [1x1 sym]
c: [1x1 sym]
d: [1x1 sym]
I am using Matlab R2010b and Win7 64bit.
Categories
Find more on Conversion Between Symbolic and Numeric 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!