The following data define the sealevel concentration of diss
Solution
(a)
% Piecewise linear interpolation:
Exact_value = 7.986;
T=[0 8 16 24 32 40];
O=[14.621 11.843 9.870 8.418 7.305 6.413];
%Create points between 0 and 40
xx=linspace (0, 40);
%Use the linear interpolation
yy=interp1(T, O, xx);
%Plot the graph
plot(T, O, ‘O’, xx, yy)
%Find the value at T=27 by linear interpolation
Est_value=interp1(T, O, 27)
%Find the error
error=abs((Exact_value-Est_value)/Exact_val)*100
(b)
% Piecewise linear interpolation:
Exact_value = 7.986;
T=[0 8 16 24 32 40];
O=[14.621 11.843 9.870 8.418 7.305 6.413];
%Create points between 0 and 40
xx=linspace (0, 40);
%Use the cubic spline
yy=spline(T, O, xx);
%Plot the graph
plot(T, O, ‘O’, xx, yy)
%Find the value at T=27 by cubic spline
Est_value=spline(T, O, 27)
%Find the error
error=abs((Exact_value-Est_value)/Exact_val)*100
