how to fit a curve in matlab?
조회 수: 11 (최근 30일)
이전 댓글 표시
i have a curve like shown and i need to make more smmoth -- can you tell the way for doing that if it is possible?

댓글 수: 0
답변 (2개)
Cris LaPierre
2023년 6월 17일
Smoothing and curve fitting are different things.
For smoothing, consider using the Smooth Data live task in a live script to interactively adjust the settings.
For curve fitting, consider the options presented here: https://www.mathworks.com/help/matlab/data_analysis/interactive-fitting.html
댓글 수: 0
John D'Errico
2023년 6월 17일
편집: John D'Errico
2023년 6월 17일
You really have very little signal, compared to what is apprently noise in those "curves". As such, you would be ill-advised to even try to perform any sophisticated smoothing OR curve fitting. At most, you might decide to model/fit them using a linear or at most a quadratic polynomial. Given as few data points as you have, smoothing will also be difficult to do at all well.
And, since you don't actually provide any data, it is even more difficult to help you. But, for example, suppose you had this data.
x = linspace(0,1,8)';
y = cos(x - 2) + randn(size(x))/3;
plot(x,y,'o')
While there may be some information content in that data, I doubt it. At most, you might dcide a straight line is all it is worth. The problem is, too often we end up overfitting our data.
Polyfit can find the coefficients of a straight line fit. Or, we could use fit. Fit is nice, if you have the curve fitting toolbox.
mdl = fit(x,y,'poly1')
plot(mdl,x,y,'o')
mdl2 = fit(x,y,'smoothingspline')
hold on
plot(mdl2,'g')
And you should see that the fit from a smoothing spline is meaningless garbage, the result of throwing a sophisticated tool at data that lacks any redemptive value. With some understanding of a smoothing spline, we COULD arguably make it do better, but the result here would not be much more than just using a simple low order polynomial model.
Simple things are often the best choices.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Smoothing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

