フィルターのクリア

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 Center および File ExchangeGet 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