Effacer les filtres
Effacer les filtres

How to make a plot smooth?

4 vues (au cours des 30 derniers jours)
Sajid Sarwar
Sajid Sarwar le 29 Juin 2019
Commenté : Star Strider le 29 Juin 2019
I have attached the fig. file of the plot and I want to make the lines smooth without running code again as it takes too much time.

Réponse acceptée

Star Strider
Star Strider le 29 Juin 2019
It depends on what you intend by ’smooth’.
Try this:
I = openfig('scma25.fig');
Ax = gca;
Lines = findobj(Ax,'Type','line');
for k = 1:numel(Lines)
X(k,:) = Lines(k).XData;
Y(k,:) = Lines(k).YData;
pv(:,k) = polyfit(X(k,:), Y(k,:), 3);
yf(k,:) = polyval(pv(:,k),X(k,:));
end
figure
semilogy(X', yf')
grid
legend(Ax.Legend.String)
xlabel(Ax.XLabel.String)
ylabel(Ax.YLabel.String)
It uses polyfit and polyval to fit your data, then plots the fitted data in a new figure. It also re-uses your axis labels and legend strings.
  2 commentaires
Sajid Sarwar
Sajid Sarwar le 29 Juin 2019
@ Star Strider thank you
Star Strider
Star Strider le 29 Juin 2019
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Log Plots dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by