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

4 visualizzazioni (ultimi 30 giorni)
Shaily_T il 30 Mag 2022
Commentato: Mathieu NOE il 31 Mag 2022
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)));
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.
##### 4 CommentiMostra 3 commenti meno recentiNascondi 3 commenti meno recenti
Mathieu NOE il 31 Mag 2022
My pleasure !

Accedi per commentare.

### Categorie

Scopri di più su Surface and Mesh Plots in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!