solving nonlinear equations
1 次查看(过去 30 天)
显示 更早的评论
Hello,
i tried to work on solving the following equations, so that the code returns values for w and theta. However this does not work in the desired way. I even tried to work with fminsearch. Does somebody know how to solve this problem?
syms w theta;
eq1 = '-0.0889=(-w^0.5*(w-1)^2*(w*(w+2)*sinh(3*theta)+3*sinh(theta)))/(sqrt(2)*(w-1)*(w*cosh(2*theta)+1)^1.5)';
eq2 = '7.2191 =(w^2*((w^4+2*w^+3*w^2-3)*cosh(4*theta)+4*(w+2)*cosh(2*theta))+3*(2*w+1))/(2*(w*cosh(2*theta)+1)^2)';
[w theta]=solve(eq1,eq2,w,theta)
thank you for your help.
0 个评论
采纳的回答
Alexander
2012-4-25
I do get the following error message:
Error using solve>processString (line 337)
' -0.0889=(-w^0.5*(w-1)^2*(w*(w+2)*sinh(3*theta)+3*sinh(theta)))/(sqrt(2)*(w-1)*(w*cosh(2*theta)+1)^1.5) ' is not a valid expression or equation.
There seems to be a problem with theta. Since theta also is a MuPAD function, the symbolic engines confuses the input. If you have MATLAB 12a or later, you should try to avoid the string syntax (note, that you need double '==' for the comparison):
syms w theta;
eq1 = -0.0889==(-w^0.5*(w-1)^2*(w*(w+2)*sinh(3*theta)+3*sinh(theta)))/(sqrt(2)*(w-1)*(w*cosh(2*theta)+1)^1.5);
eq2 = 7.2191 ==(w^2*((w^4+2*w^+3*w^2-3)*cosh(4*theta)+4*(w+2)*cosh(2*theta))+3*(2*w+1))/(2*(w*cosh(2*theta)+1)^2);
[w theta]=solve(eq1,eq2,w,theta)
This gives:
w =
0.039410543092148572708570152224833
Theta =
1.5385135630436219217489780415314
If yo have an older version of MATLAB, try replacing theta by another variable. I tried Theta, with a capital T:
syms w Theta;
eq1 = '-0.0889=(-w^0.5*(w-1)^2*(w*(w+2)*sinh(3*Theta)+3*sinh(Theta)))/(sqrt(2)*(w-1)*(w*cosh(2*Theta)+1)^1.5)';
eq2 = '7.2191 =(w^2*((w^4+2*w^+3*w^2-3)*cosh(4*Theta)+4*(w+2)*cosh(2*Theta))+3*(2*w+1))/(2*(w*cosh(2*Theta)+1)^2)';
[w Theta]=solve(eq1,eq2,w,Theta)
0 个评论
更多回答(1 个)
Sean de Wolski
2012-4-25
The expressions do nto need to be strings:
syms w theta;
eq1 = 0.0889+(-w^0.5*(w-1)^2*(w*(w+2)*sinh(3*theta)+3*sinh(theta)))/(sqrt(2)*(w-1)*(w*cosh(2*theta)+1)^1.5); %=0
eq2 = -7.2191 +(w^2*((w^4+2*w^+3*w^2-3)*cosh(4*theta)+4*(w+2)*cosh(2*theta))+3*(2*w+1))/(2*(w*cosh(2*theta)+1)^2); %=0
[w theta]=solve(eq1,eq2,w,theta)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!