matlab 最小二乘拟合这是m文件function y=nihe4(p,x)y=p(1)*x+p(2)*x^2*exp(-p(3)*x)+p(4);主程序:x=0.1:0.1:1;>> y=[2.3201,2.6470,2.9707,3.2885,3.6008,3.9090,4.2147,4.5191,4.8232,5.1275];>> p=nlinfit(x,y,'nihe4',ones(1,4));下面会出现这
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/27 02:28:23
matlab 最小二乘拟合这是m文件function y=nihe4(p,x)y=p(1)*x+p(2)*x^2*exp(-p(3)*x)+p(4);主程序:x=0.1:0.1:1;>> y=[2.3201,2.6470,2.9707,3.2885,3.6008,3.9090,4.2147,4.5191,4.8232,5.1275];>> p=nlinfit(x,y,'nihe4',ones(1,4));下面会出现这
matlab 最小二乘拟合
这是m文件
function y=nihe4(p,x)
y=p(1)*x+p(2)*x^2*exp(-p(3)*x)+p(4);
主程序:
x=0.1:0.1:1;
>> y=[2.3201,2.6470,2.9707,3.2885,3.6008,3.9090,4.2147,4.5191,4.8232,5.1275];
>> p=nlinfit(x,y,'nihe4',ones(1,4));
下面会出现这个
Caught "std::exception" Exception message is:
Message Catalog was not loaded from the file.Please check file location,format or contents
然后我输入
>> a=p(1)
a =
2.3200
>> b=p(2)
b =
-0.8203
>> c=p(3)
Attempted to access p(3); index out of bounds because numel(p)=2.
这是怎么回事?
matlab 最小二乘拟合这是m文件function y=nihe4(p,x)y=p(1)*x+p(2)*x^2*exp(-p(3)*x)+p(4);主程序:x=0.1:0.1:1;>> y=[2.3201,2.6470,2.9707,3.2885,3.6008,3.9090,4.2147,4.5191,4.8232,5.1275];>> p=nlinfit(x,y,'nihe4',ones(1,4));下面会出现这
m文件
function y=nihe4(p,x)
y=p(1)*x+p(2)*x.^2.*exp(-p(3)*x)+p(4);
主程序:
x=0.1:0.1:1;
y=[2.3201,2.6470,2.9707,3.2885,3.6008,3.9090,4.2147,4.5191,4.8232,5.1275];
p1 = nlinfit(x,y,@nihe4,ones(1,4))
计算结果
p1 =
3.1001 1.5027 4.0046 2.0000