matlab求曲线拟合后的误差,matlab拟合曲线求参数?
摘要代码示例matlab求曲线拟合后的误差:令x=(cos(k)./sin(k))./c,这个就是xdata向量y=252/(2.016129032*10^bai9)*a*x^b取log得到log(y)=
代码示例matlab求曲线拟合后的误差:
令x=(cos(k)./sin(k))./c,这个就是xdata向量
y=252/(2.016129032*10^bai9)*a*x^b
取log得到
log(y)=b*log(x)+log(252/(2.016129032*10^9)*a)
所以log(y)与log(x)是线性关系,用p=polyfit(log(xdata),log(y),1)求出
b=p(1);
a=exp(p(2))/252*(2.016129032*10^9);
%
因为log(252/(2.016129032*10^9)*a)=p(2)
所以最终程序是如下:
clear
all
c=[2.7,2.8,2.9,3,3.1,3.2,3.45,3.7,3.95,4.2,4.45,4.7,4.95,5.2];
k=[0,47,93,140,186,279,372,465,558,651];
y=[18.98,27.35,34.86,38.52,38.44,37.73,38.43,43.87,42.77,46.22];
xdata=(cos(k)./sin(k))./c;
p=polyfit(log(xdata),log(y),1);
b=p(1);
a=exp(p(2))/252*(2.016129032*10^9);