%% Akima Interpolation of Cosine Data
%
% Use makima to interpolate a cosine curve over unevenly spaced sample points.

x = [0 1 2.5 3.6 5 7 8.1 10];
y = cos(x);
xq = 0:.25:10;
yq = makima(x,y,xq);
plot(x,y,'o',xq,yq,'--')

% With oscillatory functions, the Akima algorithm flattens the curve near local extrema. To compensate for this flattening, you can add more sample points near the local extrema.
% Add sample points near x=6\ldotp 5 and x=9 and replot the interpolation.

x = [0 1 2.5 3.6 5 6.5 7 8.1 9 10];
y = cos(x);
xq = 0:.25:10;
yq = makima(x,y,xq);
plot(x,y,'o',xq,yq,'--')

% Copyright 2019 The MathWorks, Inc.