Coefficents not reflecting the curve obtained using fit function
Show older comments
I am trying to write a piece of code that outputs the constants a and b for a curve of the following format:
f(x)=1/(1+exp(1).^(b*(x-a)))
My code (below) is producing the logistic function plot (below) which i believe to be correct, however the coefficients being extracted from the code are not representative of the plot being produced. Is there a fix for this which would mean that the correct values of a and b could be extracyed from the function? Any help would be much appreciated
function [a,b] = fit_lightoff(Temperature,Gas_Conversion)
ft = fittype( '1/(1+exp(1).^(-b*(x-a)))');
options = fitoptions;
options.Normal = 'on';
f=fit(Temperature,Gas_Conversion, ft, options)
MyCoeffs=coeffvalues(f);
a= MyCoeffs(1);
b= MyCoeffs(2);
h = plot( f, Temperature,Gas_Conversion);
end

Accepted Answer
More Answers (0)
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!