I keep getting this error, "Not enough input arguments" for my fit function. How to resolve this?
Afficher commentaires plus anciens
%% Fit: 'untitled fit 1'.
[xData, yData] = prepareCurveData(time, PLkinetics );
% Set up fittype and options.
ft = fittype( 'exp2' );
excludedPoints = xData < 0.235;
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.Lower = [1253000000 -59.85 54.95 -1.791];
opts.StartPoint = [86.7593397136756 -5.83107018617984 38.6125589857038 0.495341980324732];
opts.Upper = [2.933e+15 -56.18 90 -1.35];
opts.Exclude = excludedPoints;
% 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, excludedPoints );
legend( h, 'PLkinetics vs. time', 'Excluded PLkinetics vs. time', 'untitled fit 1', 'Location', 'NorthEast', 'Interpreter', 'none' );
% Label axes
xlabel( 'time', 'Interpreter', 'none' );
ylabel( 'PLkinetics', 'Interpreter', 'none' );
grid on
Réponses (1)
You may need to share your data. When I run your code with some made up data, I do not get an error.
Please share the complete error message (all the red text)
% data for testing
time=linspace(1,5);
PLkinetics = 5*exp(time);
%% Fit: 'untitled fit 1'.
[xData, yData] = prepareCurveData(time, PLkinetics );
% Set up fittype and options.
ft = fittype( 'exp2' );
excludedPoints = xData < 0.235;
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.Lower = [1253000000 -59.85 54.95 -1.791];
opts.StartPoint = [86.7593397136756 -5.83107018617984 38.6125589857038 0.495341980324732];
opts.Upper = [2.933e+15 -56.18 90 -1.35];
opts.Exclude = excludedPoints;
% 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, excludedPoints );
1 commentaire
Naeimeh N
le 31 Déc 2022
I agree with your answer. The code works for me as well.
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
