xInitial = [1.6 1.1 .6 .1 .4 .9 1.4 1.9];
yInitial = [1 1.5 2 2.5 3 3.5 4 4.5];
lengthX = length(xInitial);
x = yInitial;
y = xInitial;
plot(x, y, '-sr', 'LineWidth', 2);
grid on;
set(gcf, 'Position', get(0,'Screensize'));
samplingRateIncrease = 10;
newXSamplePoints = linspace(min(x), max(x), lengthX * samplingRateIncrease);
smoothedY = spline(x, y, newXSamplePoints);
ySmooth = newXSamplePoints;
xSmooth = smoothedY;
hold on;
plot(newXSamplePoints, smoothedY, '-ob');
title('Spline Interpolation Demo', 'FontSize', 20);
legend('Original Points', 'Spline Points');
figure;
plot(xInitial, yInitial, '-sr', 'LineWidth', 2);
hold on;
plot(xSmooth, ySmooth, '-ob');
grid on;
Best Answer