Constraining parameters in Curve Fitting Tool

14 次查看(过去 30 天)
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.

采纳的回答

Danila Sokratov
Danila Sokratov 2019-9-16
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by