ABCs_numerical_methods

ABCs_numerical_methods - C % d) polyval. Evaluate the...

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

View Full Document Right Arrow Icon
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 = spline(x,y,xi); 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 = polyfit(x,y,3);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: C % d) polyval. Evaluate the polynomial found in part c at the points in the % vector xi. Store your result in D. % % Write your code here: D = polyval(C,xi); D % e) diff. Approximate the derivative, dy/dx, for the vectors x and y. % Store your result in E. % % Write your code here: E = diff(y)./diff(x); E % f) cumsum. Find the cumulative sum of the elements in x. Store your % result in F. % % Write your code here: F = cumsum(x); 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 = trapz(x,y); 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 = cumtrapz(x,y);...
View Full Document

This note was uploaded on 10/21/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Tech.

Ask a homework question - tutors are online