Constraining parameters in Curve Fitting Tool

21 Ansichten (letzte 30 Tage)
Emilie Veje
Emilie Veje am 22 Mai 2017
Kommentiert: John D'Errico am 16 Sep. 2019
Hello, I want to fit data to an exponential function a-(a-b)*exp(-c*x) using the Curve Fitting Tool but I want to set the limits on the 3 parameters. I want to add something like this:
options.Unknowns = [a,b,c];
options.Lower = [0,0,0];
options.Upper = [1,0.5,10];
I have generated code from the Curve Fitting Tool, so right now I have the function:
function [fitresult, gof] = createFit2(ExpT, ExpNorm_t1)
% Fit: 'untitled fit 1'.
[xData, yData] = prepareCurveData( ExpT, ExpNorm_t1 );
% Set up fittype and options.
ft = fittype( 'a-(a-b)*exp(-c*x)', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = [0.586235247766206 0.184587387921842 0.13921839531406];
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts )
% Plot fit with data.
figure( 'Name', 'Exponential Fit to Data' );
h = plot( fitresult, xData, yData);
legend( h, 'Normalized Tether Intensity vs. time', 'Exponential fil to data', 'Location', 'NorthEast');
% Label axes
xlabel Time[s]
ylabel 'Normalized Tether Intensity'
griid on
I just do not know how to specify parameter limits inside the function.

Akzeptierte Antwort

Danila Sokratov
Danila Sokratov am 16 Sep. 2019
I'm sure this is too late, but in matlab you can write fit1 = fit(xData,yData,functionToFit,'Lower',[bound1,bound2,bound3],'Upper',[same,thing,3],'StartPoint',[sp1,sp2,sp3]);
In the curve fitting tool, you can fit to a custom equation, and then click fit options, which should bring you to a menu where you can select each parameter and set limits and starting points.

Weitere Antworten (0)

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by