Fit operation with defined variables

조회 수: 1 (최근 30일)
Isac Grossa
Isac Grossa 2021년 3월 1일
댓글: Isac Grossa 2021년 3월 2일
Hi there. I have the following example of code:
mydata_x = random_data % isn't important how data i have
mydata_y = random_data
a = 10;
b = 0.5;
c = 3;
To calculate the fit of mydata I use to calculate d:
[fit1,gof1] = fit(mydata_x,mydata_y,'(10-0.5.*x.*d)/(3+0.5.*x.*d)');
There is a way to substitute 10,0.5 and 3 with the equivalent vaiables: a,b and c; like the following code:
[fit1,gof1] = fit(mydata_x,mydata_y,'(a-b.*x.*d)/(c+b.*x.*d)');

채택된 답변

Steven Lord
Steven Lord 2021년 3월 1일
See the "Create Fit Options and Fit Type Before Fitting" example on the documentation page for the fit function. It uses the 'problem' option to specify that certain variables in the expression to be fitted are problem parameters that will be specified when the expression is fitted, not coefficients whose values should be determined by the fitting process.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by