unequal_spaced_data

# unequal_spaced_data - %pp = mkpp(breaks,coefs) builds a...

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

function unequal_spaced_data(f,z,fx) %Problem 19.9 % %This function obtains first-derivative estimates for unequally spaced data %passed into the function. %1) Takes x and y values as inputs. %2) Spline fit the data points using the built-in Matlab function spline to % find the piecewise polynomial coefficients. %3) Calculate the piecewise polynominal coefficients for the first derivative % of the spline function. %4) Use the first derivative piecewise polynominal coefficients to calculate % the first derivative of the spline curve at the original x values using % the built-in Matlab function ppval. %Claculates True derivative values syms x gg1=subs(diff(f,x),x,z); %caculates 1st derivative of f and creates an %array of new fx values using z's. pp=spline(z,fx); %Cubic spline
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %pp = mkpp(breaks,coefs) builds a piecewise polynomial pp from its breaks %and coefficients. breaks is a vector of length L+1 with strictly increasing %elements which represent the start and end of each of L intervals. coefs is %an L-by-k matrix with each row coefs(i,:) containing the coefficients of %the terms, from highest to lowest exponent, of the order k polynomial on %the interval [breaks(i),breaks(i+1)]. T=pp.coefs; Coefs=[3*T(:,1),2*T(:,2),1*T(:,3)]; P=mkpp(pp.breaks,Coefs); %v = ppval(pp,xx) returns the value of the piecewise polynomial f, %contained in pp, at the entries of xx. gg2=ppval(z,P); fprintf('\nTrue derivative values=\n') fprintf('%5.4f\n',gg1) fprintf('\nSpline fit derivative values=\n') fprintf('%5.4f\n',gg2)...
View Full Document

## This note was uploaded on 09/27/2011 for the course EGM 3344 taught by Professor Raphaelhaftka during the Spring '09 term at University of Florida.

Ask a homework question - tutors are online