一元非线性回归分析中​,显示beta未定义​,请问是啥问题?。

自定义的模型函数:
function y=yut(beta,x)
y=beta(1)*x.^beta(2);
定义为yut.m文件中;同工作夹下,执行脚本:
clear;
x1=0.1:0.01:0.18;
x2=[x1,0.20,0.21,0.23]';
y=[42,41.5,45,45.5,45.0,47.5,49,55,50,55,55.5,60.5]';
beta0=[0.1,3]';
test=yut(beta0,8)
beta=nlinfit(x2,y,yut,beta0);
beta
之后成功求得test的值,推断yut函数正常工作,但是同时显示错误:
??? Input argument "beta" is undefined.
Error in ==> yut at 2
y=beta(1)*x.^beta(2);
请问高手们,哪里出现了问题?????谢谢!

 Réponse acceptée

davikeh
davikeh le 23 Nov 2022

0 votes

nlinfit 的第三个参数 modelfun 应该是一个函数句柄,所以,你的代码需要修改为:
beta=nlinfit(x2,y,@yut,beta0);

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!