I have an extremely basic question seeking to answer why the following function in MatLab does not properly fit the given data to a logistic curve, given the correct equation for one. The solution to this is likely quite simple, but I am entirely unfamiliar with the MatLab curve fitting toolbox. My code is as follows:
function [fitresult, gof] = createFit1(Dose, Response)
%CREATEFIT1(DOSE,RESPONSE)
% Create a fit.
%
% Data for 'untitled fit 1' fit:
% X Input : Dose
% Y Output: Response
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 08-Sep-2022 20:16:26
%% Fit: 'untitled fit 1'.
Dose = [1.6*10^4;1.84*10^4;2.08*10^4;2.32*10^4; 2.56*10^4;2.8*10^4;3.04*10^4;3.28*10^4;3.52*10^4;3.76*10^4;4*10^4;4.24*10^4]
Response = [0;0.1004;0.2830;0.4338;0.5638;0.6834;0.8030;0.8680;0.9294;0.9614;0.9978;1]
[xData, yData] = prepareCurveData( Dose, Response );
% Set up fittype and options.
ft = fittype( '1/(1+exp(-k*Dose))', 'independent', 'Dose', 'dependent', 'Response' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = 0.0755269568571602;
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, xData, yData );
legend( h, 'Response vs. Dose', 'untitled fit 1', 'Location', 'NorthEast', 'Interpreter', 'none' );
% Label axes
xlabel( 'Dose', 'Interpreter', 'none' );
ylabel( 'Response', 'Interpreter', 'none' );
grid on




