Clear Filters
Clear Filters

Attempting to fit data with a sigmoid curve, but not an option in curvefitter toolbox

31 views (last 30 days)
I am working on fitting data with a sigmoidal curve, but my CurveFitter toolbox does not have the sigmoidal option under fit types. I have tried a custom fit, but it is not giving me any useable fits.
eqn:
'a/(1+exp(-b*(x-c)))'

Answers (3)

Star Strider
Star Strider on 21 Aug 2024 at 19:15
Perhaps something like this —
s = fittype('a/(1+exp(-b*(x-c)))', 'Coefficients',{'a','b','c'}, 'Independent','x', 'Dependent','y')
s =
General model: s(a,b,c,x) = a/(1+exp(-b*(x-c)))
x = linspace(0, 10, 20);
y = rand(size(x));
sfit = fit(x(:), y(:), s)
Warning: Start point not provided, choosing random start point.
sfit =
General model: sfit(x) = a/(1+exp(-b*(x-c))) Coefficients (with 95% confidence bounds): a = 58.84 (-1.583e+05, 1.584e+05) b = 0.05918 (-1.317, 1.435) c = 85.92 (-4.764e+04, 4.781e+04)
figure
plot(sfit, x, y)
grid
.

Sam Chak
Sam Chak on 21 Aug 2024 at 20:01
The latest Curve Fitting Toolbox has only three Sigmoidal Curves in its library of models.
rng(0,"twister")
x = linspace(-1, 1, 101)';
y = 1./(1 + exp(- 10*x)) + 0.02*randn(101, 1);
y(y>1) = 1;
y(y<0) = 0;
logsigm = fit(x, y, 'logistic')
logsigm =
General model Logistic: logsigm(x) = a/(1 + exp(-b*(x-c))) Coefficients (with 95% confidence bounds): a = 0.9933 (0.9863, 1) b = 10.2 (9.769, 10.63) c = -0.001955 (-0.006753, 0.002844)
plot(logsigm, x, y), grid on, grid minor

Image Analyst
Image Analyst on 21 Aug 2024 at 22:16
Attach your actual data so we can work with it. In the meantime, I'm attaching my demo of fitting a sigmoid, though it uses a different formula than yours. However, you can adapt it to use your formula.

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!