ABCs_numerical_methods

ABCs_numerical_methods - % vector xi. Store your result in...

This preview shows page 1. Sign up to view the full content.

function [A, B, C, D, E, F, G, H] = ABCs_numerical_methods(x, y, xi) % ABCs of Numerical Methods % % This is a multi-part problem. Do each of the parts below. % % DO NOT CHANGE THE FUNCTION HEADER (the first line of code) % % Problem Parts: % % a) interp1. Find the y values corresponding to the x-values in xi by % interpolating based on the vectors x and y. Use linear interpolation. % Store your result in A. % % Write your code here: A = interp1(x,y,xi); A % b) spline. Find the y values corresponding to the x values in xi by % interpolating based on the vectors x and y. Use the spline method of % interpolation. Store your result in B. % % Write your code here: B = B % c) polyfit. Find the coefficients of the third order polynomial that best % fits the points represented by vectors x and y. Store your result in C. % % Write your code here: C = %<fix this line>% C % d) polyval. Evaluate the polynomial found in part c at the points in the
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % vector xi. Store your result in D. % % Write your code here: D = %&lt;fix this line&gt;% D % e) diff. Approximate the derivative, dy/dx, for the vectors x and y. % Store your result in E. % % Write your code here: E = %&lt;fix this line&gt;% E % f) cumsum. Find the cumulative sum of the elements in x. Store your % result in F. % % Write your code here: F = %&lt;fix this line&gt;% F % g) trapz. Find the area under the curve represented by x and y by using % the trapzoidal method of approximation. Store your result in G. % % Write your code here: G = %&lt;fix this line&gt;% G % h) cumtrapz. Find the cumulative area under the curve represented by x % and y by using the trapzoidal method of approximation. Store your result % in H. % % Write your code here: H = %&lt;fix this line&gt;%...
View Full Document

Ask a homework question - tutors are online