Plot the five interpolating cubic polynomials found in question 2 to show the

smooth nature of the spline. An outline of the program is shown below. The

program assumes that the coefficients of the cubic polynomials, as shown in

Table 4.9 have been stored in the 5 × 4 matrix C. The program uses the Matlab

function polyval to evaluate a polynomial at a given point.

for i = 1 : 5;

% Choose 20 equally spaced points in each interval, i

xvalues = linspace( x(i), x(i+1), 20);

% Evaluate the polynomial at each point in the interval, i

% polyval expects a vector of coefficients in descending

% order, beginning with the coefficient of the highest power

poly = C( i, : ); % select row i of C

yvalues = polyval( poly, xvalues);

plot ( xvalues, yvalues);

% After plotting the first interval, plot the rest on the same graph using

% the hold function

if interval == 1;

hold;

end;

For full details of the functions provided by Matlab for the construction and

visualisation of splines refer to the Spline Toolbox.

Solution.pdf

Submit your documents and get free Plagiarism report

Your solution is just a click away! Get it Now

By creating an account, you agree to our terms & conditions

We don't post anything without your permission

Attach Files

Get it solved from our top experts within 48hrs!