关于matlab的问题哪位高手能帮帮我啊!急!急!
>>t=[0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4,4.5,5,6,7,8,9,10,11,12,13,14,15,16];>>C=[30,68...
>> t=[0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4,4.5,5,6,7,8,9,10,11,12,13,14,15,16]; >> C=[30,68,75,82,82,77,68,68,58,51,50,41,38,35,28,25,18,15,12,10,7,7,4]; >> f=inline('k(3)*(k(1)/(k(1)-k(2))*(exp(-k(2)*t)-exp(-k(1)*t))','k','t'); >> [k,res]=lsqcurvefit(f,[1,0,82],t,C); ??? Error using ==> optim\private\lsqncommon User supplied expression or inline function ==> k(3)*(k(1)/(k(1)-k(2))*(exp(-k(2)*t)-exp(-k(1)*t)) failed with the following error: Error using ==> inlineeval Error in inline expression ==> k(3)*(k(1)/(k(1)-k(2))*(exp(-k(2)*t)-exp(-k(1)*t)) ??? Error: Missing variable or function. Error in ==> lsqcurvefit at 149 [x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ... 为什么会出现这样的问题啊?应该怎么修改!
展开
展开全部
你的inline函数有问题:少了个括号的!我不知道你到底在那里断开,自己检查吧
补充一下:
x
=
[0,1,2,3,4,5]';
y
=
[0,1,4,9,16,25]';
f
=
inline('C(1)
+
C(2)*t
+
C(3)*t.^2+
C(4)*t.^3','C','t');
ff
=
optimset;
ff.TolFun=1e-20;
ff.TolX=1e-15;
x0
=
[0,0,0,0];
%
初始值
[C,res]
=
lsqcurvefit(f,x0,x,y,[],[],ff)
y1=f(C,x);
plot(x,y,'-b',x,y1,'-or')
补充一下:
x
=
[0,1,2,3,4,5]';
y
=
[0,1,4,9,16,25]';
f
=
inline('C(1)
+
C(2)*t
+
C(3)*t.^2+
C(4)*t.^3','C','t');
ff
=
optimset;
ff.TolFun=1e-20;
ff.TolX=1e-15;
x0
=
[0,0,0,0];
%
初始值
[C,res]
=
lsqcurvefit(f,x0,x,y,[],[],ff)
y1=f(C,x);
plot(x,y,'-b',x,y1,'-or')
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询