登录论坛

查看完整版本 : [MATLAB数学相关] matlab中fsolve的问题


if_only
2009-10-31, 14:28
我编写了一个程序使用矩量法求解微分方程,代码如下
function juliangfa =juliangfa(E,P,I,L,M0,n,N)
% N is the terms of the thaler expansion %
global e4 e5 e6
alpha=P/(E*I);
k0=M0/(E*I); % k0 is the initial curvature %
syms c1 c2 c3 s
theta=c1*s+c2*s^2+c3*s^3; % the fitting funtion %
R2=2*c2+6*c3*s+alpha*n*sin0(N,theta)+alpha*cos0(N,theta); % sin0 and cos0 are the thaler expansion of sin and cos %
e1=c1+2*c2*L+3*c3*L^2-k0 % the boundary condition %
e2=int(R2,s,0,L) % e2 is one of the equations %
R21=s*R2;
e3=int(R21,s,0,L)
e4=subs(e1);
e5=subs(e2);
e6=subs(e3);
c=fsolve('fangcheng',[1,1,1]',optimset('display','off'));
end
其中cos0和sin0是我编写的一个泰勒展开式的生成程序,确定没错
子程序fangcheng的代码是:
function q=fangcheng(p)
global e4 e5 e6
c1=p(1);
c2=p(2);
c3=p(3);
q(1)=e4;
q(2)=e5;
q(3)=e6;
end
错误的提示是:
??? Undefined function or method 'full' for input arguments of type 'sym'.
Error in ==> trustnleqn at 28
Fvec = full(Fvec);
Error in ==> fsolve at 378
[x,FVAL,JACOB,EXITFLAG,OUTPUT,msg]=...
Error in ==> juliangfa at 16
c=fsolve('fangcheng',[1,1,1]',optimset('display','off'));
如果我把得到的方程直接复制来替换fangcheng中的e4,e5,e6,使用c=fsolve('fangcheng',[1,1,1]',optimset('display','off'));就能得到结果
但是用我的一上程序就出现错误,求高人指点!