필터 지우기
필터 지우기

How to fit my data with an array instead of standard functions?

조회 수: 4 (최근 30일)
Nishant Pathak
Nishant Pathak 2023년 1월 4일
편집: Torsten 2023년 1월 4일
I have an x-data and y-data as an array. I want to fit it with another function made from another array instead of standard functions like 'poly2' etc. Here is a simplified example of the problem. In my work the fitting function may not be any standard function (i.e. which cannot be written analytically).
x=[0;1;2;3;4;5;6;7;8;9;10]; %x Data
y=[0;1;3;9;16;23;36;50;64;84;99]; %y Data
f=fit(x,y,'poly2') % standard way of fitting
plot(f,x,y) %plotting the fit
%% Instead of 'poly2' I want to use fit_funtion to fit my data which is made of an array of data points, z
% z=[0;1;4;9;16;25;36;49;64;81;100]
% fit_funtion= p1*z.^2+p2*z+p3 % p1, p2, p3 are the coefficients to fit
Instead of 'poly2' I want to use fit_funtion to fit my data which is made of an array of data points, z
z=[0;1;4;9;16;25;36;49;64;81;100]
and my fitting function is made of a combination of z as below
fit_funtion=p1*z^{2}+p2*z+p3
where p1, p2, p3 are the coefficients to fit.
Is there any technique availabe in MATLAB to do this kind of fitting?
  댓글 수: 1
Torsten
Torsten 2023년 1월 4일
편집: Torsten 2023년 1월 4일
Look at the examples
Fit a Curve Defined by a File
or
Fit a Custom Model Using an Anonymous Function
under

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

답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by