| 5 | 1/1 | 返回列表 |
| 查看: 2208 | 回復(fù): 4 | ||||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | ||||
劉小嵩321銀蟲 (著名寫手)
|
[求助]
matlab出現(xiàn)問題 已有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)為時(shí)間零點(diǎn),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 is delta 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; 執(zhí)行命令時(shí)出現(xiàn): 錯誤使用 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); 應(yīng)該如何修改? |
銀蟲 (著名寫手)
榮譽(yù)版主 (著名寫手)
![]() |
專家經(jīng)驗(yàn): +4 |
|
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); |

銀蟲 (著名寫手)
|
還是報(bào)錯, 出錯 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. |
金蟲 (初入文壇)
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 340求調(diào)劑 +6 | Amber00 2026-03-26 | 6/300 |
|
|---|---|---|---|---|
|
[考研] 0856材料化工調(diào)劑 總分330 +14 | zhubinhao 2026-03-27 | 14/700 |
|
|
[考研] 材料學(xué)碩333求調(diào)劑 +11 | 北道巷 2026-03-24 | 11/550 |
|
|
[碩博家園] 求調(diào)劑 有機(jī)化學(xué)考研356分 +3 | Nadiums 2026-03-25 | 4/200 |
|
|
[考研] 一志愿太原理工安全工程300分,求調(diào)劑 +5 | 0857求調(diào)劑. 2026-03-24 | 6/300 |
|
|
[考研] 本科新能源科學(xué)與工程,一志愿華理能動285求調(diào)劑 +7 | AZMK 2026-03-28 | 11/550 |
|
|
[考研] 291求調(diào)劑 +6 | HanBeiNingZC 2026-03-24 | 6/300 |
|
|
[考研] 308求調(diào)劑 +7 | 墨墨漠 2026-03-27 | 7/350 |
|
|
[考研] 安徽大學(xué)專碩生物與醫(yī)藥專業(yè)(086000)324分,英語已過四六級,六級521,求調(diào)劑 +4 | 美味可樂雞翅 2026-03-26 | 4/200 |
|
|
[考研] 考研化學(xué)308分求調(diào)劑 +10 | 你好明天你好 2026-03-23 | 12/600 |
|
|
[考研] 348求調(diào)劑 +4 | 小懶蟲不懶了 2026-03-27 | 5/250 |
|
|
[考研] 一志愿211,335分,0856,求調(diào)劑院校和導(dǎo)師 +4 | 傾____蕭 2026-03-27 | 5/250 |
|
|
[考研] 考研調(diào)劑 +10 | 呼呼?~+123456 2026-03-24 | 10/500 |
|
|
[考研] 327求調(diào)劑 +7 | prayer13 2026-03-23 | 7/350 |
|
|
[考研] 調(diào)劑 +4 | 柚柚yoyo 2026-03-26 | 4/200 |
|
|
[考研] 化學(xué)工程085602 305分求調(diào)劑 +17 | RichLi_ 2026-03-25 | 17/850 |
|
|
[考研] 材料科學(xué)與工程 317求調(diào)劑 +4 | JKSOIID 2026-03-26 | 4/200 |
|
|
[考研] 081700 調(diào)劑 267分 +11 | 迷人的哈哈 2026-03-23 | 11/550 |
|
|
[考研] 一志愿 南京郵電大學(xué) 288分 材料考研 求調(diào)劑 +3 | jl0720 2026-03-26 | 3/150 |
|
|
[考研] 材料與化工328分調(diào)劑 +6 | 。,。,。,。i 2026-03-23 | 6/300 |
|