x1=[32 24 18 13.5];
y1=[675 1050 1580 2487];
p=polyfit(log(x1),log(y1),1) %多项式拟合,p为多项式系数,最后的1为要拟合成的阶数
x2=10:0.1:50;
y2=exp(polyval(p,log(x2)));
loglog(x1,y1,'*',x2,y2,'-')
运行结果如下
x=[32,24,18,13.5];
y=[675,1050,1580,2487] ;
x1=log10(x);
y1=log10(y);
p=polyfit(x1,y1,1);
yy=polyval(p,x1);
plot(x1,y1,'o')
hold on
plot(x1,yy,'-r')
xlabel('Log(x)')
ylabel('Log(y)')