defining fitting curve to measured data

조회 수: 2 (최근 30일)
Elisbeth Brandner
Elisbeth Brandner 2021년 8월 26일
편집: Roshan Hingnekar 2021년 9월 2일
Hi, i try to find a fitting function for my measured data. Sadly i do not come to a good result. my last try was based on defining a fitting type. but i just get errors. the matrix distance_data contains the measurement results. in the first colum is stored the distance and the ones after are the measurment values. the value of the measurment results decrease by increasing distance. this means the measurement curve goes from high value at low distance and low measurment value at high distance. for this behavioure i am looking for a estimation method/ fitting function.
fo = fitoptions('Method','NonlinearLeastSquares',...
'Lower',[0,0],...
'Upper',[Inf,max(distance_data(:,1))],...
'StartPoint',[1 1]);
Unrecognized function or variable 'distance_data'.
ft = fittype('(a/(x+b))^n','problem','n','options',fo);
fitobject = fit(distance_data(:,1),distance_data(:,material_index),'ft');
[curve2,gof2] = fit(distance_data(:,1),distance_data(:,material_index),ft,'problem',2)
[curve3,gof3] = fit(distance_data(:,1),distance_data(:,material_index),ft,'problem',3)
hold on
plot(curve2,'m')
plot(curve3,'c')
legend('Data','n=2','n=3')
hold off
by performing the code in this way i get following error:
>> fo = fitoptions('Method','NonlinearLeastSquares',...
'Lower',[0,0],...
'Upper',[Inf,max(distance_data(:,1))],...
'StartPoint',[1 1]);
ft = fittype('(a/(x+b))^n','problem','n','options',fo);
fitobject = fit(distance_data(:,1),distance_data(:,material_index),'ft');
Error using fittype>iCreateFromLibrary (line 414)
Library function ft not found.
Error in fittype>iCreateFittype (line 345)
obj = iCreateFromLibrary( obj, varargin{:} );
Error in fittype (line 330)
obj = iCreateFittype( obj, varargin{:} );
Error in fit>iFit (line 165)
model = fittype( fittypeobj, 'numindep', size( xdatain, 2 ) );
Error in fit (line 116)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
>>
do you have a idea what i am doing wrong ?
do you have another way to perform a curve fitting with the option to add some basic function (eg: y=1/x or y=cos(x))?
thanks in advance for your support !
  댓글 수: 1
Rik
Rik 2021년 8월 26일
What happens if you try this?
fitobject = fit(distance_data(:,1),distance_data(:,material_index),ft);

댓글을 달려면 로그인하십시오.

답변 (1개)

Roshan Hingnekar
Roshan Hingnekar 2021년 9월 2일
편집: Roshan Hingnekar 2021년 9월 2일
Refer to the following documentation on How to fit a curve
Also use the curve fitting toolbox for increased efficiency

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by