parametricspline

parametricspline - % % ti = vector compared with ti =

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

View Full Document Right Arrow Icon
function [xi,yi,ti] = paramSpline(x,y,n) % paramSpline Parametric spline interpolation. % % Synopsis: [xi,yi,ti] = paramSpline(x,y) % [xi,yi,ti] = paramSpline(x,y,n) % % Input: x,y = vectors of data defining a curve in (x,y) plane % n = (optional) number of points to generate on the % interpolated curve. Default: n = 100 % % Output: xi,yi = vectors of points on parametric curves x = xi(ti) % and y = yi(ti) obtained from seperate cubic % spline interpolations of x and y. Plotting (xi,yi) % produces a smooth curve through the (x,y) data.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % % ti = vector compared with ti = linspace(min(t),max(t),n) % where t = 1:length(x) is a vector of indices for x and % y, and n is an optional input patameter. if nargin<2, error('not enough input patameters'); end if nargin<3, n = 100; end t=1:length(x); ti=linspace(min(t),max(t),n); xi=splint(t,x,ti); yi=splint(t,y,ti); plot(x,y,'o',xi,yi,'-'), xlabel('X'), ylabel('Y'), title('Cubic Spline Interpolation'), axis([-1 4 0 6]); I %%>>x=[0,1,2,2,3]; %%>>y=[1,3,3,4,5]; %%>>[xi,yi,ti]=paramSpline(x,y); %...
View Full Document

This note was uploaded on 09/11/2011 for the course MECH 231 taught by Professor Den during the Spring '11 term at Rutgers.

Ask a homework question - tutors are online