function interpolation_example
% aynartisi interpolation_example
% sthn sinartisi ayti pragmatopoieitai gramiki kai kibiki paremboli metaxi
% ton simion toy anismatos x
% oi times y (pinakas y) anaparista to imitono toy pinaka x (ton simion x)
%
% to x_perisotera fiaxnei simia metaxi ton simion x
%
% to y_perisotera fiaxnei ta sin simia toy x_perisotera me pragmatopoihsh
% parembolis  1 = gramiki paremboli
%             2 = kibiki paremboli spline

x = -2*pi:pi/3:2*pi;
y = sin(x);

x_perisotera = -2*pi:pi/12:2*pi;


subplot(2,1,1)
y_perisotera = interp1(x,y,x_perisotera);
plot(x,y,'o',x_perisotera,y_perisotera,'r--');
xlim([-2*pi 2*pi]);
ylim([-1.2 1.2]);
title('GRAMIKI PAREMBOLI METAXI TON SHMEION');


subplot(2,1,2)
y_perisotera = interp1(x,y,x_perisotera,'spline');
plot(x,y,'o',x_perisotera,y_perisotera,'r--');
xlim([-2*pi 2*pi]);
ylim([-1.2 1.2]);
title('KIBIKI PAREMBOLI SPLINE METAXY TON SIMION');