%
% Un ejemplo de fiteo.
%
close all;
figure;
axes('FontSize', 14);

clear xdata ydata;
xdata = 0:0.01:pi;
ydata = sin(xdata);
wdata = 0 * xdata + 1;
%
plot(xdata, ydata, 'LineWidth', 2, 'Color', 'b');
xlim([0 pi]);
ylim([0 1.05]);

GradoDelPolinomio = 12;

clear coefs;
coefs = ajustarpol(GradoDelPolinomio, wdata, xdata, ydata);

n1 = GradoDelPolinomio + 1;
n2 = GradoDelPolinomio + 2;
clear icoefs;
for i = 1:n1
  icoefs(n2 - i) = coefs(i);
end

fpol = @(x) polyval(icoefs, x);

hold on;
fplot(fpol, [0 pi], 'r');

