x=[0:5:30];
p=[0.00,0.058,-2.094,33.88,-246.6,688,-181.0];
y=polyval(p,x);
plot(x,y,'r')
x=0:5:30;
y=[0.00,0.058,-2.094,33.88,-246.6,688,-181.0];
p=ployfit(x,y,2); % 2表示二階擬合,階數越高,曲線越理想
disp('二階擬合'),f=poly2str(p,'x'); % f表示擬合的二階函數
x1=0:2:30; %縮小取值間隔
y1=polyval(p,x1); %polyval多項式函數p在x1處的值
plot(x1,y1,'r-')