How to best fit a curve to my data

46 views (last 30 days)
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')
And here's what I get:
Any ideas what the code should be to receive a fit more similar to what I drew?
Iddo Weiner
Iddo Weiner on 5 Dec 2017
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:
  • But I would still like to know if there's a "native" MATLAB solution for this..

Sign in to comment.

Accepted Answer

Matt J
Matt J on 5 Dec 2017

More Answers (1)

Rik on 5 Dec 2017
You need to change the starting guesses and you might have to adjust the function itself.
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.

Community Treasure Hunt

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

Start Hunting!