How to make smooth curve on figure?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a matlab figure which has noisy data. I want to plot a smooth curve for those data. Can anyone help on this issue?
댓글 수: 0
답변 (1개)
Star Strider
2015년 4월 6일
The Savitzky-Golay filter (Signal Processing Toolbox sgolayfilt function) is probably best for your application:
F = openfig('smooth.fig');
x = get(get(gca, 'Children'), 'XData');
y = get(get(gca, 'Children'), 'YData');
x = x(~isnan(y));
y = y(~isnan(y));
b = sgolayfilt(y, 3, fix(length(y)/2));
hold on
plot(x, b, '-r')
hold off
Experiment with the filter polynomial order and frame length to get the result you want.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!