echo on
clear all

x = 0:.1:10;
y = sin(x)+cos(2*x);
k5 = polyfit(x,y,5);
y5 = polyval(k5, x);
k11 = polyfit(x,y,11);
y11 = polyval(k11, x);

clf
plot(x, y, 'g', x, y5, 'r', x, y11, 'b') 

title('Curve Fitting', 'Fontsize',14)
legend('Original Curve', '5th order', '11th order',4 )
set(findobj('Type', 'line'), 'LineWidth', 2)

echo off
shg
