matlab解非线性方程组fsolve出现错误
代码如下:functionq=myfun(p)x=p(1);y=p(2);q(1)=y*k(1,1)*(pg(1,1)+exp(-y^2/2)*1/(1+tang2(1,...
代码如下:function q = myfun(p)
x=p(1);
y=p(2);
q(1)=y*k(1,1)*(pg(1,1)+exp(-y^2/2)*1/(1+tang2(1,1)/x))-4*(ref5(1,1)-((1+2*u(1,1))/(1+2*sqrt(1-y)*u(1,1))*(1+2*(u0(1,1)))/ (1+2*sqrt(1-y)*(u0(1,1)))-1));
q(2)=y*k4(1,1)*(pg4(1,1)+exp(-y^2/2)*1/(1+tang24(1,1)/x))-4*(ref54(1,1)-((1+2*u4(1,1))/(1+2*sqrt(1-y)*u4(1,1))*(1+2*(u04(1,1)))/ (1+2*sqrt(1-y)*(u04(1,1)))-1));
x=fsolve('myfun',[0.5,0.5]',optimset('Display','off'));
错误是:
??? Undefined function or method 'k' for input arguments of type 'double'.
Error in ==> myfun at 12
q(1)=y*k(1,1)*(pg(1,1)+exp(-y^2/2)*1/(1+tang2(1,1)/x))-4*(ref5(1,1)-((1+2*u(1,1))/(1+2*sqrt(1-y)*u(1,1))*(1+2*(u0(1,1)))/
(1+2*sqrt(1-y)*(u0(1,1)))-1));
Error in ==> fsolve at 254
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue. 展开
x=p(1);
y=p(2);
q(1)=y*k(1,1)*(pg(1,1)+exp(-y^2/2)*1/(1+tang2(1,1)/x))-4*(ref5(1,1)-((1+2*u(1,1))/(1+2*sqrt(1-y)*u(1,1))*(1+2*(u0(1,1)))/ (1+2*sqrt(1-y)*(u0(1,1)))-1));
q(2)=y*k4(1,1)*(pg4(1,1)+exp(-y^2/2)*1/(1+tang24(1,1)/x))-4*(ref54(1,1)-((1+2*u4(1,1))/(1+2*sqrt(1-y)*u4(1,1))*(1+2*(u04(1,1)))/ (1+2*sqrt(1-y)*(u04(1,1)))-1));
x=fsolve('myfun',[0.5,0.5]',optimset('Display','off'));
错误是:
??? Undefined function or method 'k' for input arguments of type 'double'.
Error in ==> myfun at 12
q(1)=y*k(1,1)*(pg(1,1)+exp(-y^2/2)*1/(1+tang2(1,1)/x))-4*(ref5(1,1)-((1+2*u(1,1))/(1+2*sqrt(1-y)*u(1,1))*(1+2*(u0(1,1)))/
(1+2*sqrt(1-y)*(u0(1,1)))-1));
Error in ==> fsolve at 254
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue. 展开
展开全部
matlab解非线性方程组fsolve出现错误,应这样来解决。
1、在function q = myfun(p)后面,应增加下列k、pg等矩阵数据
A=load('matlab1109.mat');
b=A.b; %[400x304 double]
c=A.c;
cosg=A.cosg;
cosg4=A.cosg4;
k=A.k;
k4=A.k4;
mie=A.mie;
mie4=A.mie4;
pg=A.pg;
pg4=A.pg4;
ref5=A.ref5;
ref54=A.ref54;
u0=A.u0;
u04=A.u04;
u=A.u;
u4=A.u4;
tang2=A.tang2;
tang24=A.tang24;
2、对于p(1)和p(2)表达式中的乘,除关系,应用 点运算 方法来表示。
1、在function q = myfun(p)后面,应增加下列k、pg等矩阵数据
A=load('matlab1109.mat');
b=A.b; %[400x304 double]
c=A.c;
cosg=A.cosg;
cosg4=A.cosg4;
k=A.k;
k4=A.k4;
mie=A.mie;
mie4=A.mie4;
pg=A.pg;
pg4=A.pg4;
ref5=A.ref5;
ref54=A.ref54;
u0=A.u0;
u04=A.u04;
u=A.u;
u4=A.u4;
tang2=A.tang2;
tang24=A.tang24;
2、对于p(1)和p(2)表达式中的乘,除关系,应用 点运算 方法来表示。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询