Sie sind auf Seite 1von 1

% Plotten der Funktionen

x = linspace(-5,5,101);
for k = 1:2
subplot(2,2,k*2-1)
hold on;
plot(x,polyval(ci{k*2-1},x),'r-','LineWidth',2);
plot(x,polyval(ci{k*2},x),'b-','LineWidth',2);
plot(x,f(x),'k-');
axis tight;
axis square;
grid on;
title('f(x) = 1/(1+x^2)');
legend(['P_{' num2str(k*5) ', equidistant}'], ...
['P_{' num2str(k*5) ', Chebyshev}'],'exact');
end
for k = 1:2
subplot(2,2,k*2)
hold on;
plot(x,abs((f(x)-polyval(ci{k*2-1},x))),'r-','LineWidth',2);
plot(x,abs((f(x)-polyval(ci{k*2},x))),'b-','LineWidth',2);
axis tight;
axis square;
grid on;
title('Error Plot');
ylabel('absolute error');
end

Das könnte Ihnen auch gefallen