getting a wrong solution to a simple linear system using "solve"
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (1)
Friedrich
le 1 Avr 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 commentaires
uri albocher
le 1 Avr 2011
Friedrich
le 1 Avr 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.
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!