曲线拟合已知方程y=a*x^b+(1-a)*x^c,还有(0.863,0.7),(0.768,0.5),(0.665,0.3),(0.554,0.2),(0.456,0.123),(0.356,0.052),(0.254,0.024),(0.123,0.012),(0.092,0.0098)数据是已知,怎样求a,b,学了好几天matl
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/29 07:14:15
曲线拟合已知方程y=a*x^b+(1-a)*x^c,还有(0.863,0.7),(0.768,0.5),(0.665,0.3),(0.554,0.2),(0.456,0.123),(0.356,0.052),(0.254,0.024),(0.123,0.012),(0.092,0.0098)数据是已知,怎样求a,b,学了好几天matl
曲线拟合
已知方程y=a*x^b+(1-a)*x^c,还有(0.863,0.7),(0.768,0.5),(0.665,0.3),(0.554,0.2),(0.456,0.123),(0.356,0.052),(0.254,0.024),(0.123,0.012),(0.092,0.0098)数据是已知,怎样求a,b,
学了好几天matlab没会,
曲线拟合已知方程y=a*x^b+(1-a)*x^c,还有(0.863,0.7),(0.768,0.5),(0.665,0.3),(0.554,0.2),(0.456,0.123),(0.356,0.052),(0.254,0.024),(0.123,0.012),(0.092,0.0098)数据是已知,怎样求a,b,学了好几天matl
帮你试了一下,可以这么做:
首先,将以下数据用文本文档形式保存为c4.txt
0.863 0.7
0.768 0.5
0.665 0.3
0.554 0.2
0.456 0.123
0.356 0.052
0.254 0.024
0.123 0.012
0.092 0.0098
并记住,将这个c4.txt文件放在你的MATLAB安装目录的work文件夹下
接着,编制如下M文件:
%模型设定
function yhat=modef(beta0,x)
a=beta0(1);
b=beta0(2);
c=beta0(3);
yhat=a.*x.^b+(1-a).*x.^c;
将以上程序保存为modef.m文件,放在你的MATLAB安装目录的work文件夹下
然后,在MATLAB命令窗口中输入如下命令:
%模型参数估计
data=load('c4.txt');
x=data(:,1)';
y=data(:,2)';
beta0=[0.6,2,2];
[beta,R,J]=nlinfit(x,y,'modef',beta0);
beta
m1=beta(1);
m2=beta(2);
m3=beta(3);
yy=m1.*x.^m2+(1-m1).*x.^m3;
plot(x,y,'+',x,yy)
得到的输出结果是:
beta =
0.8655
2.7129
2.7127
也就说,模型估计出来为:
y=0.8655*x^2.7129+(1-0.8655)*x^2.7127
好难! 不会啊