Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Question 4.
- % Parts b and c. Using monomial basis...
- figure(1)
- x = [0 0.5 1];
- V = vander(x);
- y = exp(x)';
- c = V\y;
- % c =
- % 0.841678574117578
- % 0.876603254341467
- % 1.000000000000000
- x_vals = linspace(0,1,50);
- y_vals = exp(x_vals);
- plot(x_vals,y_vals);
- hold on
- y_est = polyval(c,x_vals);
- plot(x_vals,y_est,'r');
- % Part d - plot absolute error.
- figure(2)
- semilogy(abs(y_vals - y_est))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement