clear clc close all y = [1 2 2.2 3 2.8 4.5 5 8 9]; x = 1:length(y); x1 = 1:.1:length(y); for order = 1:4 coeff = polyfit(x, y, order); subplot(2, 2, order) plot(x, y,'r+') hold on y1 = polyval(coeff, x1); plot(x1, y1) end