Professor Diomar Cesar Lobao

Universidade Federal Fluminense-Volta Redonda, RJ, Brasil

Diomar Cesar


Dept. Ciências Exatas - Exact Science Dept.

Search

splineex.m

% demonstrate spline and polyint functions

clear;                                 % clear variables

min = -5;                              % range of x values
max = 5;
x = min:1:max;                         % define x values

y = sin(x);	                       % define y values

xi = min:0.1:max;                      % x values to be interpolated at
yi = spline(x,y,xi);                   % spline interpolation
yii = polyint(x,y,xi);                 % polynomial interpolation

plot (x,y,'o',xi,yi,'-',xi,yii,'-.');  % plot and compare

legend('raw data','cubic spline','poly inter');
Skip to content