필터 지우기
필터 지우기

How to make a plot smooth?

조회 수: 4 (최근 30일)
Sajid Sarwar
Sajid Sarwar 2019년 6월 29일
댓글: Star Strider 2019년 6월 29일
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.

채택된 답변

Star Strider
Star Strider 2019년 6월 29일
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
Sajid Sarwar
Sajid Sarwar 2019년 6월 29일
@ Star Strider thank you
Star Strider
Star Strider 2019년 6월 29일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Log Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by