24小时热门版块排行榜    

查看: 2207  |  回复: 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的回帖

刘小嵩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的回帖
查看全部 5 个回答

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的回帖

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的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 求调剂 +5 林之夕 2026-03-24 5/250 2026-03-24 17:16 by dick_runner
[考研] 289求调剂 +5 硕星赴 2026-03-23 5/250 2026-03-24 17:09 by hello七七
[考研] 300求调剂,材料科学英一数二 +5 leaflight 2026-03-24 5/250 2026-03-24 16:25 by laoshidan
[考研] 生物学学硕求调剂 +6 小羊睡着了? 2026-03-23 6/300 2026-03-24 13:22 by 李常安
[考研] 081700 调剂 267分 +9 迷人的哈哈 2026-03-23 9/450 2026-03-24 11:58 by 544594351
[考研] 生物学一志愿985,分数349求调剂 +6 zxts12 2026-03-21 9/450 2026-03-23 18:37 by macy2011
[考研] 311求调剂 +6 冬十三 2026-03-18 6/300 2026-03-22 20:18 by edmund7
[考研] 318求调剂 +4 plum李子 2026-03-21 7/350 2026-03-22 14:17 by ColorlessPI
[考研] 考研调剂 +4 来好运来来来 2026-03-21 4/200 2026-03-22 12:15 by 星空星月
[基金申请] 山东省面上项目限额评审 +4 石瑞0426 2026-03-19 4/200 2026-03-22 08:50 by Wei_ren
[考研] 286分人工智能专业请求调剂愿意跨考! +4 lemonzzn 2026-03-17 8/400 2026-03-21 22:49 by lemonzzn
[考研] 278求调剂 +9 烟火先于春 2026-03-17 9/450 2026-03-21 17:47 by 学员8dgXkO
[考研] 0703化学297求调剂 +3 Daisy☆ 2026-03-20 3/150 2026-03-21 17:45 by ColorlessPI
[考研] 材料 271求调剂 +5 展信悦_ 2026-03-21 5/250 2026-03-21 17:29 by 学员8dgXkO
[考研] 一志愿南昌大学,327分,材料与化工085600 +9 Ncdx123456 2026-03-19 9/450 2026-03-20 23:41 by lovewei0727
[考研] 一志愿 南京航空航天大学大学 ,080500材料科学与工程学硕 +5 @taotao 2026-03-20 5/250 2026-03-20 20:16 by JourneyLucky
[考研] 一志愿南理工085701环境302求调剂院校 +3 葵梓卫队 2026-03-20 3/150 2026-03-20 19:28 by zhukairuo
[考研] 招收调剂硕士 +4 lidianxing 2026-03-19 12/600 2026-03-20 12:25 by lidianxing
[考研] 0703化学调剂 +5 pupcoco 2026-03-17 8/400 2026-03-19 13:58 by houyaoxu
[考研] 收复试调剂生 +4 雨后秋荷 2026-03-18 4/200 2026-03-18 14:16 by elevennnne
信息提示
请填处理意见