MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB数学相关] 请帮忙看看这个matlab 自定义函数非线性拟合的代码有什么问题?谢谢 (https://www.labfans.com/bbs/showthread.php?t=18624)

宇天 2012-12-27 11:32

请帮忙看看这个matlab 自定义函数非线性拟合的代码有什么问题?谢谢
 
想要调用matlab的Psi函数进行相关的非线性拟合,在已经导入x和y数据后,我写了以下代码

mf=@(p,x)(1.5*(log(p(1)*x)+psi(1/p(1)/x+0.5))-0.5*(log(p(2)*x)+psi(1/p(2)/x+0.5)));

P=[1;1];

Pc=nlinfit(x,y,mf,P);

但是编译时提示以下错误,请高手帮忙看看哪里的问题,如何改 谢谢

Error using nlinfit (line 121)
Error evaluating model function
'@(p,x)(1.5*(log(p(1)*x)+psi(1/p(1)/x+0.5))-0.5*(log(p(2)*x)+psi(1/p(2)/x+0.5)))'.

Error in nonlinefit (line 3)
Pc=nlinfit(x,y,mf,P);

Caused by:
Error using +
Matrix dimensions must agree.


所有时间均为北京时间。现在的时间是 14:49

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.