24小时热门版块排行榜    

查看: 2205  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 293求调剂 +6 加一一九 2026-03-24 6/300 2026-03-24 14:29 by JourneyLucky
[考研] 一志愿哈工大,085400,320,求调剂 +3 gdlf9999 2026-03-24 3/150 2026-03-24 10:08 by 搏击518
[考博] 26申博自荐 +3 whh869393 2026-03-24 3/150 2026-03-24 09:55 by 21018060
[考研] 327求调剂 +5 prayer13 2026-03-23 5/250 2026-03-23 22:11 by 星空星月
[考研] 384求调剂 +3 子系博 2026-03-22 6/300 2026-03-23 21:45 by 子系博
[论文投稿] 急发核心期刊论文 +3 贤达问津 2026-03-23 5/250 2026-03-23 17:13 by 妹子不好惹
[考研] 328求调剂 +4 LHHL66 2026-03-23 4/200 2026-03-23 14:55 by lbsjt
[考研] 生物学调剂 +5 Surekei 2026-03-21 5/250 2026-03-22 14:39 by tcx007
[基金申请] 山东省面上项目限额评审 +4 石瑞0426 2026-03-19 4/200 2026-03-22 08:50 by Wei_ren
[考研] 求助 +5 梦里的无言 2026-03-21 6/300 2026-03-21 17:51 by 学员8dgXkO
[考研] 278求调剂 +9 烟火先于春 2026-03-17 9/450 2026-03-21 17:47 by 学员8dgXkO
[基金申请] 学校已经提交到NSFC,还能修改吗? 40+4 babangida 2026-03-19 9/450 2026-03-21 16:12 by babangida
[考研] 一志愿华南师大 070300(化学)304分求调剂 +3 0703武芊慧雪304 2026-03-18 3/150 2026-03-21 00:48 by JourneyLucky
[考研] 274求调剂 +10 S.H1 2026-03-18 10/500 2026-03-20 23:51 by JourneyLucky
[考研] 330求调剂 +4 小材化本科 2026-03-18 4/200 2026-03-20 23:13 by JourneyLucky
[考研] 求调剂一志愿南京航空航天大学289分 +3 @taotao 2026-03-19 3/150 2026-03-20 21:34 by JourneyLucky
[考研] 295复试调剂 +8 简木ChuFront 2026-03-19 8/400 2026-03-20 20:44 by zhukairuo
[考研] 材料学求调剂 +4 Stella_Yao 2026-03-20 4/200 2026-03-20 20:28 by ms629
[考研] 求调剂 +3 @taotao 2026-03-20 3/150 2026-03-20 19:35 by JourneyLucky
[考研] 0856调剂,是学校就去 +8 sllhht 2026-03-19 9/450 2026-03-20 14:25 by 无懈可击111
信息提示
请填处理意见