Warning: Explicit solution could not be found.
Mostrar comentarios más antiguos
I use 'solve' code to solve 3 variables and 3 equations.
My program is :
function QQQ=fff(u,v);
syms Xc Yc Zc;
format compact;
format long;
r=7;
Xa=-0.50028822921022;
Ya=0;
Za=5.00288229210220;
Xo=6.25865746822572;
Yo=1.69110011226519;
Zo=5.67877686184579;
sol=solve((Xa-Xo)*(Xc-Xo)+(Ya-Yo)*(Yc-Yo)+(Za-Zo)*(Zc-Zo)-r*r*cosd(18.60992783662224),(Xo-Xa)*(Xc-Xa)+(Yo-Ya)*(Yc-Ya)+(Zo-Za)*(Zc-Za)-2*(r^2)*sind(9.30496391831112)*cosd(80.69503608168888),(Xo-Xc)*(Xa-Xc)+(Yo-Yc)*(Ya-Yc)+(Zo-Zc)*(Za-Zc)-2*(r^2)*sind(9.30496391831112)*cosd(80.69503608168888),Xc,Yc,Zc)
But result is :
Warning: Explicit solution could not be found.
> In solve at 140
In sym.solve at 49
In SLP2 at 12
sol =
[ empty sym ]
I want to find Xc、Yc、Zc answer.
How can I do ?
Respuesta aceptada
Más respuestas (1)
Matt Tearle
el 1 de Feb. de 2013
Editada: Matt Tearle
el 1 de Feb. de 2013
solve is trying to do an analytic solve, which turns out to be too hard to do. But everything in your equations are defined numerically (except the variables you're trying to solve for), so are you trying to get numerical values for the unknowns, or do you need the formulae for some reason? If you just need the values, you could use fsolve (if you have Optimization TB):
r=7;
Xa=-0.50028822921022;
Ya=0;
Za=5.00288229210220;
Xo=6.25865746822572;
Yo=1.69110011226519;
Zo=5.67877686184579;
sol=fsolve(@(Xc) [(Xa-Xo)*(Xc(1)-Xo)+(Ya-Yo)*(Xc(2)-Yo)+(Za-Zo)*(Xc(3)-Zo)-r*r*cosd(18.60992783662224),(Xo-Xa)*(Xc(1)-Xa)+(Yo-Ya)*(Xc(2)-Ya)+(Zo-Za)*(Xc(3)-Za)-2*(r^2)*sind(9.30496391831112)*cosd(80.69503608168888),(Xo-Xc(1))*(Xa-Xc(1))+(Yo-Xc(2))*(Ya-Xc(2))+(Zo-Xc(3))*(Za-Xc(3))-2*(r^2)*sind(9.30496391831112)*cosd(80.69503608168888)],rand(3,1))
But... it looks like your equations are actually linear in Xc, Yc, Zc. So I'd suggest rearranging the equations in matrix-vector form and solve with \. EDIT TO ADD Oops, no, I just noticed that the last equation is quadratic in Xc, Yc, Zc. Never mind.
(Also, this all seems to be happening inside a function, with no reference to the function inputs. This is inefficient if the function is going to be called numerous times, because solving these equations is independent of the function inputs and will therefore produce the same result each time.)
1 comentario
Chia-Ching
el 2 de Feb. de 2013
Categorías
Más información sobre Systems of Nonlinear Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!