程式碼示例:
令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);
程式碼示例:
令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);