How can I minimize an objective function using lsqnonlin? I am minimizing the difference between theoretical S parameter and measured S-parameter to extract the dielectric constant?

4 Ansichten (letzte 30 Tage)
The function has complex values and every time I change the initial value example: x0 = 1-1i the value of dielectric constant changes. I think something is wrong with the optimization process here.
F = Reflx_tot_thy-refl_cmplx_measrd;
x = lsqnonlin(F,x0)
er = real(x)-i*imag(x)

Akzeptierte Antwort

Alan Weiss
Alan Weiss am 29 Aug. 2016
Perhaps your function has multiple local minima. Perhaps your function F is not specified correctly (is it a function handle?). I do not understand why you take er as real(x) - i*imag(x) when I would think that you should add the imaginary part, and maybe should take er = F(x) instead of er = x.
It is difficult to know without seeing more details, and a formula of what the dielectric constant is as a function of x.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 Kommentar
Ankit Regmi
Ankit Regmi am 30 Aug. 2016
% I am calculating the dielectric constant as a function of angle of incidence. Currently I am calculating at a single frequency with diffrenent incidence angle data for S21(oblique incidence) and will compare the results of this data at single angle with the measured frequency range. Thus, I am having the same problem and you are right about the multiple local minimum. My code is attached below, dont know where the problem is coming from.
function F = constant(x,t,d,w,c,S21)
er = x;
gama = (1i*w*sqrt(er))/c;
reflx_thy_n = zeros(1,length(t));
reflx_thy_d = zeros(1,length(t));
reflx_thy = zeros(1,length(t));
Reflx_totn = zeros(1,length(t));
Reflx_totd = zeros(1,length(t));
Reflx_tot = zeros(1,length(t));
for i = 1:length(t)
reflx_thy_n(1,i) = cos(t(i))-sqrt(er-sin(t(i)).^2);
reflx_thy_d(1,i) = cos(t(i))+sqrt(er-sin(t(i).^2));
reflx_thy(1,i) = reflx_thy_n(i)./reflx_thy_d(i);
% Total Reflection Coefficient Calculation
Reflx_totn(1,i) = 1-exp(-2*gama*d/cos(t(i)))*(reflx_thy(i));
Reflx_totd (1,i)= 1-reflx_thy(i)^2*exp(-2*gama*d/cos(t(i)));
Reflx_tot(1,i) = Reflx_totn(i)/Reflx_totd(i);
end
F = (Reflx_tot-refl_cmplx);
end
% Main Code
t = [0.83,0.97,1.01];
fre = 1.03075e+09;
e_v = 8.854e-12;
mu_v = 4*pi*10^-7;
c = 1/sqrt(e_v*mu_v);
lamda = c/fre;
w = 2*pi*fre;
S21 = ......(measured complex data)
F = @(x)constant(x,t,d,w,c,S21);
opts = optimoptions(@lsqnonlin,'Algorithm','levenberg-marquardt','Display','iter');
x0 = 3-0.025i;
[x1,resnorm,residuals,exitflag,output] = lsqnonlin(F,x0,[],[],opts); x1,resnorm,exitflag,output.iterations
er = x1;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Alan Weiss
Alan Weiss am 30 Aug. 2016
I am surprised that this code works at all, because I do not see where refl_cmplx is defined.
Even if that is not a real issue, I suggest that you take a wide variety of initial values x0. And it seems to me that you might have better luck if you scale some of your parameters. e_v*mu_v is of order 1e-20, which might be giving you some trouble.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  3 Kommentare
Alan Weiss
Alan Weiss am 31 Aug. 2016
That is a hard question in general. See what the documentation has to say about it. And, since you seem to have a low-dimensional problem, you might be able to take a set of x0 that cover the space pretty well.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by