Constraining parameters in Curve Fitting Tool

15 visualizaciones (últimos 30 días)
Emilie Veje
Emilie Veje el 22 de Mayo de 2017
Comentada: John D'Errico el 16 de Sept. de 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.

Respuesta aceptada

Danila Sokratov
Danila Sokratov el 16 de Sept. de 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.

Más respuestas (0)

Categorías

Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by