% Harjutustund 8, ylesanne 2
x=[2014:2023];
y=[22.2,19.5,18.0,17.9,25.2,18.6,18.7,29.3,15.0,21.2];
plot(x,y,'o')
grid on
% a) esimese astme polünoom
p1=polyfit(x,y,1)
% Phi(x)=0.0715x-123.7933
yp1=polyval(p1,x);
hold on
plot(x,yp1)
% prognoos x=2024
polyval(p1,2024)
% b) neljanda astme polünoom
p4=polyfit(x,y,4)
yp4=polyval(p4,x);
hold on
plot(x,yp4)
polyval(p4,2024)