matlab中inline函数的使用问题代码如下:>> 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];>> c2=[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('a(1)*exp(-a(3)*t)*((exp(a(3)*t)-1)/a
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/25 20:21:33
matlab中inline函数的使用问题代码如下:>> 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];>> c2=[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('a(1)*exp(-a(3)*t)*((exp(a(3)*t)-1)/a
matlab中inline函数的使用问题
代码如下:
>> 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];
>> c2=[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('a(1)*exp(-a(3)*t)*((exp(a(3)*t)-1)/a(3)-(exp(a(3)*t-a(2)*t)-1)/(a(3)-a(2)))','a','t');
>> [a,J]=lsqcurvefit(f,[102.04,2,1],t,c2);
? Error using ==> inlineeval at 15
Error in inline expression ==> a(1)*exp(-a(3)*t)*((exp(a(3)*t)-1)/a(3)-(exp(a(3)*t-a(2)*t)-1)/(a(3)-a(2)))
Inner matrix dimensions must agree.
Error in ==> inline.feval at 36
INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in ==> lsqcurvefit at 209
initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. LSQCURVEFIT cannot continue.
请教一下,如何修改程序代码?
matlab中inline函数的使用问题代码如下:>> 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];>> c2=[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('a(1)*exp(-a(3)*t)*((exp(a(3)*t)-1)/a
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];
c2=[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('a(1)*exp(-a(3)*t).*((exp(a(3)*t)-1)/a(3)-(exp(a(3)*t-a(2)*t)-1)/(a(3)-a(2)))','a','t');%%中间有个地方需要加个点,不过你的初值不好啊,没结果
[a,J]=lsqcurvefit(f,[102.04,2,1],t,c2);