Warning: Explicit solution could not be found.
1 次查看(过去 30 天)
显示 更早的评论
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 ?
0 个评论
采纳的回答
Walter Roberson
2013-2-2
If you add together your first two equations and simplify(), you will find that Xc, Yc, and Zc all drop out, leaving a constant. As the right side of the two is implicitly 0, and 0+0=0 but adding the two does not give 0, the equations are inconsistent, so there is no solution to the trio of equations.
更多回答(1 个)
Matt Tearle
2013-2-1
编辑:Matt Tearle
2013-2-1
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.)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Systems of Nonlinear Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!