error using solve for equation with one unknown

4 views (last 30 days)
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!

Answers (1)

Zoltán Csáti
Zoltán Csáti on 8 Dec 2014
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 Comments
Zoltán Csáti
Zoltán Csáti on 8 Dec 2014
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.

Sign in to comment.

Categories

Find more on Symbolic Math Toolbox 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!