24小时热门版块排行榜    

查看: 2164  |  回复: 4

刘小嵩321

银虫 (著名写手)

[求助] matlab出现问题 已有2人参与

1 function deconvolution
2 data=load('0.10-645.dat');
3 xdata=data(:,1);
4 ydata=data(:,2);
5 x0=[0.1];
6 %x(1)为脉宽,x(2)为时间零点,x(3)为A1,x(4)为t1,x(5)为A2,x(6)为t2
7 %-----------------------------------------------------------
8 options=optimset('TolFun',1e-4,'TolX',1e-4,'MaxIter',1e9,'MaxFunEvals',1e9);
9 [x,resnorm,residual,exitflag,output]=lsqcurvefit(@fun,x0,xdata,ydata,options);
10 disp('the fitted parameter isdelta   mu   A1   tau1   A2   tau2)');disp(x);
11 disp('the resnorm is:');disp(resnorm);
12 disp('the exit flag is:');disp(exitflag);
13 disp(output);
14 %--------------------------------------------------------------------------fit
15 Fp=fun(x,xdata);
16 irf=-1*2*sqrt(log(2))/0.06/sqrt(pi)*exp(-log(2)*(2*(xdata-x(2))/x(1)).^2)/20;
17 subplot(2,1,1); plot(data(:,1),Fp,'b-',xdata,ydata,'ro',xdata,irf,'g');
18 subplot(2,1,2); plot(data(:,1),residual,'g*');
19 %-------------------------------------------------------------------------
20 result=[xdata ydata Fp residual irf];
21 save -ASCII -DOUBLE result.dat result;
22 y=[x resnorm];
23 save -ASCII -DOUBLE parameters.dat y;
24 function F=fun(x,xdata)
25   delta1=x(1)/(sqrt(log(4)));
26    F1=x(3).*exp(delta1^2/x(4)^2/2).*exp(-(xdata-x(2))/x(4)).*(1+erf(((xdata-x(2))/delta1-delta1/x(4))/sqrt(2)));
27    F2=x(5).*(1+erf((xdata-x(7))/sqrt(2)/delta1)-exp(delta1^2/x(6)^2/2).*exp(-(xdata-x(7))/x(6)).*(1+erf(((xdata-x(7))/delta1-delta1/x(6))/sqrt(2))));
28    F=F1+F2;
执行命令时出现:
错误使用 lsqcurvefit (line 181)
LSQCURVEFIT requires the following inputs to be of data type double: 'LB'.

出错 Untitled2 (line 9)
[x,resnorm,residual,exitflag,output]=lsqcurvefit(@fun,x0,xdata,ydata,options);
应该如何修改?
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

感谢参与,应助指数 +1
X = lsqcurvefit(FUN,X0,XDATA,YDATA,LB,UB,OPTIONS) minimizes with the
    default parameters replaced by values in the structure OPTIONS, an
    argument created with the OPTIMSET function. See OPTIMSET for details.
    Use the Jacobian option to specify that FUN also returns a second output
    argument J that is the Jacobian matrix at the point X. If FUN returns
    a vector F of m components when X has length n, then J is an m-by-n matrix
    where J(i,j) is the partial derivative of F(i) with respect to x(j).
    (Note that the Jacobian J is the transpose of the gradient of F.)
改为[x,resnorm,residual,exitflag,output]=lsqcurvefit(@fun,x0,xdata,ydata,[],[],options);
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
2楼2016-03-25 14:19:03
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

刘小嵩321

银虫 (著名写手)

引用回帖:
2楼: Originally posted by dbb627 at 2016-03-25 14:19:03
X = lsqcurvefit(FUN,X0,XDATA,YDATA,LB,UB,OPTIONS) minimizes with the
    default parameters replaced by values in the structure OPTIONS, an
    argument created with the OPTIMSET function. See OPTI ...

还是报错,
出错 Untitled2 (line 9)
[x,resnorm,residual,exitflag,output]=lsqcurvefit(@fun,x0,xdata,ydata,[],[],options);

原因:
    Failure in initial user-supplied objective function evaluation. LSQCURVEFIT cannot continue.

» 本帖附件资源列表

  • 欢迎监督和反馈:小木虫仅提供交流平台,不对该内容负责。
    本内容由用户自主发布,如果其内容涉及到知识产权问题,其责任在于用户本人,如对版权有异议,请联系邮箱:xiaomuchong@tal.com
  • 附件 1 : QQ截图20160325165443.png
  • 2016-03-25 16:55:21, 48.95 K
3楼2016-03-25 16:55:43
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

0羲小?q0

金虫 (初入文坛)

【答案】应助回帖

感谢参与,应助指数 +1
源文件发来,我试着调试一下
4楼2016-03-25 18:29:00
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

刘小嵩321

银虫 (著名写手)

引用回帖:
4楼: Originally posted by 0羲小?q0 at 2016-03-25 18:29:00
源文件发来,我试着调试一下

好的,今天发给你看看,谢谢

发自小木虫IOS客户端
5楼2016-03-28 07:08:06
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 刘小嵩321 的主题更新
信息提示
请填处理意见