怎么用MATLAB求解隐性函数方程有一个很简单的方程我用MATLAB解不出,如下:q=0;s=('70*cos(q)+130*(1-(90*sin(p)-70*sin(q))/130)^0.5-90*cos(p)=150');p=solve('s')我想解是"P"值,最后得出的系空值,是不是最后一步的问
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/24 20:20:01
怎么用MATLAB求解隐性函数方程有一个很简单的方程我用MATLAB解不出,如下:q=0;s=('70*cos(q)+130*(1-(90*sin(p)-70*sin(q))/130)^0.5-90*cos(p)=150');p=solve('s')我想解是"P"值,最后得出的系空值,是不是最后一步的问
怎么用MATLAB求解隐性函数方程
有一个很简单的方程我用MATLAB解不出,如下:
q=0;
s=('70*cos(q)+130*(1-(90*sin(p)-70*sin(q))/130)^0.5-90*cos(p)=150');
p=solve('s')
我想解是"P"值,最后得出的系空值,是不是最后一步的问题?
q=0;
s=('70*cos(q)+130*(1-(90*sin(p)-70*sin(q))/130)^0.5-90*cos(p)=150');
>> p=solve(s)
Quit:
Error using ==> maple
at offset 7,`]` unexpected
Error in ==> D:\应用程序\MATLAB1\toolbox\symbolic\@sym\findsym.m
On line 53 ==> v = maple(['sort(',v,',lexorder)']);
Error in ==> D:\应用程序\MATLAB1\toolbox\symbolic\solve.m
On line 97 ==> vars = ['[' findsym(sym(eqns),neqns) ']'];
按你们俩个说的再试了一遍,出现以上两种错误,还是不行,
怎么用MATLAB求解隐性函数方程有一个很简单的方程我用MATLAB解不出,如下:q=0;s=('70*cos(q)+130*(1-(90*sin(p)-70*sin(q))/130)^0.5-90*cos(p)=150');p=solve('s')我想解是"P"值,最后得出的系空值,是不是最后一步的问
solve是解解析解的,如果没有解析解,就返回空值.
没有解析解,可用fsolve解数值解.
另外用solve时,定义全要符号变量:
syms p q s
s=70*cos(q)+130*(1-(90*sin(p)-70*sin(q))/130)^0.5-90*cos(p)=150
subs(s,q,0) % 把q换成0
ans =
130*(1 - (9*sin(p))/13)^(1/2) - 90*cos(p) - 80
>> solve(ans)
ans =
2*atan(39/112 - ((7439*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/784 - 9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/1568 - (99333*6^(1/2)*((351*2^(1/2)*3^(1/2)*649357^(1/2))/5488 + 175451/1568)^(1/2))/175616)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/4)) - (9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)))
2*atan(((7439*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/784 - 9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/1568 - (99333*6^(1/2)*((351*2^(1/2)*3^(1/2)*649357^(1/2))/5488 + 175451/1568)^(1/2))/175616)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/4)) - (9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)) + 39/112)
2*atan((9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)) - ((7439*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/784 - 9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/1568 + (99333*6^(1/2)*((351*2^(1/2)*3^(1/2)*649357^(1/2))/5488 + 175451/1568)^(1/2))/175616)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/4)) + 39/112)
2*atan((9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)) + ((7439*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/784 - 9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/1568 + (99333*6^(1/2)*((351*2^(1/2)*3^(1/2)*649357^(1/2))/5488 + 175451/1568)^(1/2))/175616)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/4)) + 39/112)
看来有解析解,算了二十秒~~~
转化成数值
double(ans)~~~~又用了二十秒
ans =
2.6198 - 1.5555i
2.6198 + 1.5555i
-0.6117
1.6553
一共有四个解
你上面的问题,s已经先定义为字符串了,为什么solve时还要加''.
q=0;
s=sym('70*cos(q)+130*(1-(90*sin(p)-70*sin(q))/130)^0.5-90*cos(p)=150');
p=solve(s,'q')
很easy啊,你把最后一句改成p=solve(s),保证ok!!