Inconsistency in the fitted curve and the plot of obtained fitting parameters
1 次查看(过去 30 天)
显示 更早的评论
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1015360/image.jpeg)
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!
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geometry and Mesh 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!