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

1 回表示 (過去 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.
Mathieu NOE
Mathieu NOE 2022 年 5 月 31 日
My pleasure !

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeGeometry and Mesh についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by