Inconsistency in the fitted curve and the plot of obtained fitting parameters

조회 수: 2 (최근 30일)
Shaily_T
Shaily_T 2022년 5월 30일
댓글: Mathieu NOE 2022년 5월 31일
I am trying to fit an equation to a model and I need to call a function "kkrebook2" in my fit type funtion (For "kkrebook2", the inputs are two vectors and its output is a vector). I have attached the way I call "kkrebook2" in my fit type function. When I run my fit code I see the obtained fitted curve (red figure) is different from the plot of the fit type function by using the obtained fitting parameters (yellow figure) which doesn't make sense. This is what I see:
This is the snippet of my fit type function code where I call "kkrebook2" function.
function p = SCR(nu,numGaussians,a,center,sigma)
for i = 1:length(nu)
for k = 1 : numGaussians
if k==1
b = Start;
else
b = Start + (center * (k-1));
end
thisGaussian(i) = a.*exp(-((nu(i)-b).^2)/(2.*(sigma.^2)));
% Add into accumulator array:
gaussEqn1(i) = gaussEqn1(i) + thisGaussian(i);
z(i)= gaussEqn1(i);
end
end
Rn = kkrebook2(nu,z,0);
for i = 1:length(nu)
hi2(i) = (4*pi*n.*nu(i)*L)/c;
hi1(i)=(Rn(i));
f(i)=(-r1+r2*exp(-(z(i))).*exp(-1i*hi1(i)).*exp(-1i*hi2(i)));
g(i)=(1-r1*r2*exp(-(z(i))).*exp(-1i*hi1(i)).*exp(-1i*hi2(i)));
h(i)= f(i)./g(i);
m(i)= abs(h(i));
p(i)= (m(i).^2);
end
end
I have also attached "kkrebook2" function that I call in my code.
Could you please let me know where is the problem? I think it should be in the way I am calling "kkrebook2" but I cannot capture it.
Thanks in advance!
  댓글 수: 4
Shaily_T
Shaily_T 2022년 5월 30일
@Mathieu NOE Thank you so much for your response! I appreciate that.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by