Constraining parameters in Curve Fitting Tool
조회 수: 22 (최근 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.
댓글 수: 0
채택된 답변
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 Center 및 File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!