% Harjutustund 10, ylesanne 4
% andmed kirja ja joonisele
x=[0:0.25:1.25];
y=[0,25,49.4,73,96.4,119.4];
plot(x,y,'o')
% 1) l2hendame andmeid lineaarsplainiga S^(1,0)(x)
y1s=interp1(x,y,x,'linear') % saime S^(1,0)(x) v22rtused
interp1(x,y,0.4,'linear') % S^(1,0)(0.4)=39.6400
hold on
plot(x,y1s,'r')
% 2) l2hendame andmeid kuupsplainiga S^(3,2)(x)
xx=[0:0.01:1.25];
y3s=interp1(x,y,xx,'spline'); % S^(3,2)(xx) v22rtused
hold on
plot(xx,y3s,'b')
% 3) aeg, mis kulub 0.45 miili l2bimiseks
interp1(x,y,0.45,'linear') % 44.52
interp1(x,y,0.45,'spline') % 44.59