defining fitting curve to measured data

4 visualizaciones (últimos 30 días)
Elisbeth Brandner
Elisbeth Brandner el 26 de Ag. de 2021
Editada: Roshan Hingnekar el 2 de Sept. de 2021
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 comentario
Rik
Rik el 26 de Ag. de 2021
What happens if you try this?
fitobject = fit(distance_data(:,1),distance_data(:,material_index),ft);

Iniciar sesión para comentar.

Respuestas (1)

Roshan Hingnekar
Roshan Hingnekar el 2 de Sept. de 2021
Editada: Roshan Hingnekar el 2 de Sept. de 2021
Refer to the following documentation on How to fit a curve
Also use the curve fitting toolbox for increased efficiency

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by