%% Step 3
%% Introduction to Step 3
% In Step 2, you wrote a subfunction to calculate the maximum of a function.   When everything is complete - you will have had to start with a set of coupled, non-linear ordinary differential equations.   There will be some data processing required to get from that to where we need to be to use your subfunction.   The next two steps help bridge the transition from the solution of the differential equations to the finding the maximum.    It would be instructive if, after the exercise, you augmented the flowchart below with additional detail.
%
%% Your Assignment
% In this step, you will take a set of data points \left\lbrace t,x\right\rbrace, plot them, interpolate them with a cubic spline and then plot the interpolating function on the same figure.

clear;
% Interpolating Function to Fit Data

% Data Set
tp=[0    0.1429    0.2857    0.4286    0.5714    0.7143    0.8571    1.0000    1.1429    1.2857    1.4286    1.5714    1.7143    1.8571    2.0000];
xp=[0    0.2072    0.3761    0.5032    0.5875    0.6304    0.6351    0.6065    0.5506    0.4737    0.3827    0.2842    0.1841    0.0879    0.0000];


% Your code goes here.


%% Solution

clear;
% Interpolating Function to Fit Data

% Data Set
tp=[0    0.1429    0.2857    0.4286    0.5714    0.7143    0.8571    1.0000    1.1429    1.2857    1.4286    1.5714    1.7143    1.8571    2.0000];
xp=[0    0.2072    0.3761    0.5032    0.5875    0.6304    0.6351    0.6065    0.5506    0.4737    0.3827    0.2842    0.1841    0.0879    0.0000];
trange=[min(tp),max(tp)];

% Plot Data
plot(tp,xp,'*k');
grid on;

% Create Cubic Spline Coefficients
pp=spline(tp,xp);

% Define Function Interpolating Data Set
f=@(s)ppval(pp,s);

% Plot Interpolating Function
hold on; fplot(f,trange,'b'); hold off;