how can I fit a composite function

조회 수: 8 (최근 30일)
Edoardo Vicentini
Edoardo Vicentini 2019년 7월 9일
편집: Dheeraj Singh 2019년 7월 24일
I have (x,y) data and i would like to fit the function of parameter()
with
with
How can I do it?
  댓글 수: 1
Rik
Rik 2019년 7월 9일
Have a read here and here. It will greatly improve your chances of getting an answer.
What have you tried so far? Can you provide a realistic sample of data so we can show how different fitting methods perform?

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

답변 (1개)

Dheeraj Singh
Dheeraj Singh 2019년 7월 24일
편집: Dheeraj Singh 2019년 7월 24일
There are many ways of fitting parameters to the data.
Firstly, you can form the equations in the following manner:
z= @(x0,w,x) (x-x0)/w;
X= @(x0,w,m,x) 1-z(x0,w,x).^2+m^2;
r= @(x0,w,m,x) sqrt(X(x0,w,m,x).^2+4*z(x0,w,x).^2);
S1= @(a0,x0,w,m,x) (1- a0*sqrt(r(x0,w,m,x)+X(x0,w,m,x))./r(x0,w,m,x));
S2= @(a0,x0,w,m,x) a0.*(-z(x0,w,x).*sqrt(r(x0,w,m,x)+X(x0,w,m,x))+sign(z(x0,w,x)).*sqrt(r(x0,w,m,x)-X(x0,w,m,x)))./(m*r(x0,w,m,x));
yfunc= @(params,x) params(1)*S1(params(3),params(4),params(5),params(6),x) + params(2)*S2(params(3),params(4),params(5),params(6),x);
For fitting the parameters, you can do in the following manner depending upon your data:
%size of x and y =200
y=linspace(0,200,200);
x=rand(200,1);
%initial values of parameters
params0=rand(6,1);
params=fminsearch(@(params) norm(y-yfunc(params,x)),params0);
For more information on Parameter fitting refer to the following link:
You can also refer to the Curve Fitting Toolbox:

카테고리

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