MATLAB: How to use spline for a fig. file

spline on figure

Can I use spline to smooth the plot in attached file?

Best Answer

Try this:
I = openfig('fft scma 25.fig');
Ax = gca;
lgnd = Ax.Legend;
Lines = findobj(Ax,'Type','line');
N = 5; % Interpolation Points Length Multiplication
for k = 1:numel(Lines)
X(k,:) = Lines(k).XData;
Y(k,:) = Lines(k).YData;
xq(k,:) = linspace(min(X(k,:)),max(X(k,:)), numel(X(k,:))*N); % Interpolation Points Vector
ys(k,:) = spline(X(k,:),Y(k,:),xq(k,:)); % Spline Fit To Data
end
figure
semilogy(xq', ys')
grid
legend(Ax.Legend.String)
xlabel(Ax.XLabel.String)
ylabel(Ax.YLabel.String)
Change ‘N’ to get the result you want.
This is essentially the same as my previous code, this time doing a spline interpolation.
EDIT —
Corrected typographical error. Code unchanged.