MATLAB: Help with Smooth graph interpolation

interp1interpolation

I have two columns of data imported from excel in workspace labelled as "Sample 1". How can I take those columns and make a smooth graph? They are both 88 rows long with column 1 being my X values and column 2 being my Y values. Thank you!

Best Answer

I have no idea what your data are, and I am not certain what defines ‘smooth’.
With that proviso, try this:
xq = linspace(min(Sample_1(:,1)), max(Sample_1(:,1)), numel(Sample_1(:,1))*10);
yq = interp1(Sample_1(:,1), Sample_1(:,2), xq', 'pchip');
figure
plot(Sample_1(:,1), Sample_1(:,2), 'xb')
hold on
plot(xq, yq, '-r')
hold off
grid
Experiment with the interp1 function 'method' arguments to get different results.
.