error using solve for equation with one unknown
2 次查看(过去 30 天)
显示 更早的评论
Hi!
I am triyng to solve for 'p' with the code:
g = linspace(0*(pi/180),180*(pi/180),10);
a = 0.7644;
b = 0.2101;
cof = 0.2;
eq = solve('(1+g)*cos(p*pi)*(sin(p*g)^2-p^2*sin(g)^2)+(1/2)*(1-a)*sin(p*pi)*(sin(2*p*g)+p*sin(2*g))+cof*sin(p*pi)*((1-a)*p*(1+p)*sin(g)^2-2*b*(sin(p*g)^2-p^2*sin(g)^2))','p');
u = subs(eq,g);
and I get the following error:
Warning: Cannot find explicit solution. > In solve at 319 In stress_int at 56 Error using symengine (line 58) Number of elements in NEW must match number in OLD.
Error in sym/subs>mupadsubs (line 139) G = mupadmex('symobj::fullsubs',F.s,X2,Y2);
Error in sym/subs (line 124) G = mupadsubs(F,X,Y);
Error in stress_int (line 57) u = subs(eq,g);
Any ideas why? Please help!
0 个评论
回答(1 个)
Zoltán Csáti
2014-12-8
The values of a, b, cof are not retained in the string, so use
syms p
solve((1+g)*cos(p*pi)*(sin(p*g)^2-p^2*sin(g)^2)+(1/2)*(1-a)*sin(p*pi)*(sin(
2*p*g)+p*sin(2*g))+cof*sin(p*pi)*((1-a)*p*(1+p)*sin(g)^2-2*b*(sin(p*g)^2-p^2*sin(g)^2)),p);
instead. But g is a vector so you will get an overdetermined system.
3 个评论
Zoltán Csáti
2014-12-8
It returned the same warning for me too. It means, that the Symbolic Math Toolbox could not solve it for p. I tried it with Maple and that couldn't solve it either. So try to solve it numerically, you can't do other things.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!