Nonlinear curve fitting, how to ?

조회 수: 2 (최근 30일)
Arsalan
Arsalan 2014년 6월 28일
답변: Arsalan 2014년 6월 28일
Hi,
I have two nonlinear functions defining the response of a system in frequency domain
H(f;Y0,Z0)= Z / ((j*2*pi*f)+(j*2*pi*f*Y0)+Z0)
H(f;Y1,Z1)= Z / ((j*2*pi*f)+(j*2*pi*f*Y1)+Z1)
to see the difference in two responses in decibles I introduce S(f) as
S(f) = 20*log(H(f;Y1,Z1)/H(f;Y0, Z0))
I also have predetermined values for S(f) obtained from experimental work where in both cases f is a known vector.
My main aim is to find values for Y1, Z1, Y0, Z0 through optimization in order to fit
S(f) = 20*log(H(f;Y1,Z1)/H(f;Y0, Z0))
to my experimental readings
How can I best achieve this ?

채택된 답변

the cyclist
the cyclist 2014년 6월 28일
If you have the Statistics Toolbox, you should be able to do this with the nlinfit() function.
  댓글 수: 4
the cyclist
the cyclist 2014년 6월 28일
I expect you have a coding error. Those data look like they could be fit just fine with nlinfit, assuming you have the proper functional form defined.
Here is a very simple example of nlinfit:
rng(1)
% Here is an example of using nlinfit(). For simplicity, none of
% of the fitted parameters are actually nonlinear!
% Define the data to be fit
x=(0:1:10)'; % Explanatory variable
y = 5 + 3*x + 7*x.^2; % Response variable (if response were perfect)
y = y + 2*randn((size(x)));% Add some noise to response variable
% Define function that will be used to fit data
% (F is a vector of fitting parameters)
f = @(F,x) F(1) + F(2).*x + F(3).*x.^2;
F_fitted = nlinfit(x,y,f,[1 1 1]);
% Display fitted coefficients
disp(['F = ',num2str(F_fitted)])
% Plot the data and fit
figure
plot(x,y,'*',x,f(F_fitted,x),'g');
legend('data','fit')
the cyclist
the cyclist 2014년 6월 28일
Would love to see the final, better fit, if you don't mind posting.

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

추가 답변 (1개)

Arsalan
Arsalan 2014년 6월 28일
Hi,
The issue was with the ordering of my four initial condition two were two high in value. the fitting is as follows now
My next step is to make things quite more complicated, by expanding constants Z and Y in equations I presented in
H(f;Y0,Z0)= Z0 / ((j*2*pi*f)+(j*2*pi*f*Y0)+Z0)
H(f;Y1,Z1)= Z1 / ((j*2*pi*f)+(j*2*pi*f*Y1)+Z1)
Y0, Y1, Z0 and Z1 can be expanded further, where they are made of 9 unknown varialbes (g, S, eS, tn, OCF, N, Nt, tp, tn)
A0 = g*(S/(1+eS)) + 1/tn - OCF*g(N-Nt)*(1/(1+eS).^2) + 1/tp
B0 = g*(S/(1+eS))*1/tp + (Be-1)*(OCF*g/tn)*(1/(1+eS).^2) + 1/(tn*tp)
A1 = g*(S/(1+eS)) + 1/tn - OCF*g(N-Nt)*(1/(1+eS).^2) + 1/tp
B2 = g*(S/(1+eS))*1/tp + (Be-1)*(OCF*g/tn)*(1/(1+eS).^2) + 1/(tn*tp)
My main aim is to find values for these 9 varialbes based on some initial values. integrating A0, B0, A1, and B2 into the fitting equation S(f), the fitting routine comes with values for the 9 parameters but gives the following fit.
do you think 9 paramaters is just too much ??? or I am making a mistake somewhere
Thanks

카테고리

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