How to best fit a curve to my data

조회 수: 6 (최근 30일)
Iddo Weiner
Iddo Weiner 2017년 12월 5일
댓글: Iddo Weiner 2017년 12월 5일
Hi, I have 2 variables (attached in the file myXY.mat) to which I would like to fit a curve.
I'm expecting to receive something like this (the pic is manually drawn):
Here's my code:
f = fit(X,Y,'exp1')
plot(f,X,Y)
And here's what I get:
Any ideas what the code should be to receive a fit more similar to what I drew?
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2017년 12월 5일
Iddo - have you tried a polynomial fit instead? i.e. poly2 or poly3?
Iddo Weiner
Iddo Weiner 2017년 12월 5일
Hi, I tried it now, but it doesn't really get any better.
What actually is working for me now is a function called sigm_fit which I found in the file exchange:
https://www.mathworks.com/matlabcentral/fileexchange/42641-sigm-fit
  • But I would still like to know if there's a "native" MATLAB solution for this..
Thanks

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

채택된 답변

Matt J
Matt J 2017년 12월 5일
f=fit(X,Y,'power2')

추가 답변 (1개)

Rik
Rik 2017년 12월 5일
You need to change the starting guesses and you might have to adjust the function itself.
x=0:0.01:10;
y=1-exp(-x);
plot(x,y)
The code above will result in a similar shape of what you are asking. 'exp1' will support this, except for the offset. You can provide your own function instead by using the anonymous function input.
PS you need to make sure that for your application, it is indeed an exponential function and not a (square) root.

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by