%
% Interpolación lineal básica.
%

senexp = @(x) (exp(-x / 2) .* sin((exp(x) - 1) / 2));

xtable = 0:0.1:5;
ytable = senexp(xtable);
ntable = length(xtable);

interpol(2.7182821, ntable, xtable, ytable)

xfun = 0:0.001:5;
yfun = senexp(xfun);

close all;
plot(xfun, yfun, '-g');
hold on;

yint = xfun;

for i = 1:length(xfun)
  yint(i) = interpol(xfun(i), ntable, xtable, ytable);
end

plot(xfun, yint, 'sr');
hold on;
plot(xtable, ytable, 'ob');
