Constraining parameters in Curve Fitting Tool
25 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Emilie Veje
le 22 Mai 2017
Commenté : John D'Errico
le 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.
0 commentaires
Réponse acceptée
Danila Sokratov
le 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.
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!