Problems in finding a set of global minima

Hi all, I have some problems in finding a set of local minimum of some complicated function. I use fminbnd but it only returns one single minium from the range of -50 to 50, but in fact there are 17 minima. How can I find the correct set of minima and save them into an array?
clear;
L=1;
L1=L/6;
omega0 = 0;
omegaR = 10;
tR= (2*pi)/omegaR;
te = 0.8;
t1 = 0;
t_i = te/50;
gamma_i = 1;
%alpha = (t_i^2)/(2*L);
alpha = (2*pi*gamma_i)/(omegaR*L) ;
beta = sqrt(1-te^2);
delta = sqrt(1-t1^2);
figure(1);
k = -54:0.01:54
k = 1×10801
-54.0000 -53.9900 -53.9800 -53.9700 -53.9600 -53.9500 -53.9400 -53.9300 -53.9200 -53.9100 -53.9000 -53.8900 -53.8800 -53.8700 -53.8600 -53.8500 -53.8400 -53.8300 -53.8200 -53.8100 -53.8000 -53.7900 -53.7800 -53.7700 -53.7600 -53.7500 -53.7400 -53.7300 -53.7200 -53.7100
a3 = (sqrt(1-te^2) - (te^2) ./ (1./(delta*exp(i*(k*L + i*alpha*L)) - (t1^2)*exp(i*( (k*L + i*alpha*L) + (k*L1 + i*alpha*L1) ))./(1- (sqrt(1-t1^2))*exp(i*(k*L1 + i*alpha*L1)))) - sqrt(1-te^2)));
a3norm = abs(a3);
plot(k,a3norm, 'LineWidth',1)
axis([-54 54 0 0.9 ])
xlabel('unnormalized m')
ylabel('T')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%% Finding Minimum %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
syms k;
k = fminbnd(@(k)abs((sqrt(1-te^2) - (te^2) ./ (1./(delta*exp(i*(k*L + i*alpha*L)) - (t1^2)*exp(i*( (k*L + i*alpha*L) + (k*L1 + i*alpha*L1) ))./(1- (sqrt(1-t1^2))*exp(i*(k*L1 + i*alpha*L1)))) - sqrt(1-te^2)))),-50,50)
k = -3.5172e-13

 Réponse acceptée

Dyuman Joshi
Dyuman Joshi le 25 Juil 2023
Modifié(e) : Dyuman Joshi le 25 Juil 2023
Functions like fminbnd (and fzero, etc) work differently than what you are expecting them to work like.
It would be better to use islocalmin in this case.
clear;
L=1;
L1=L/6;
omega0 = 0;
omegaR = 10;
tR= (2*pi)/omegaR;
te = 0.8;
t1 = 0;
t_i = te/50;
gamma_i = 1;
%alpha = (t_i^2)/(2*L);
alpha = (2*pi*gamma_i)/(omegaR*L) ;
beta = sqrt(1-te^2);
delta = sqrt(1-t1^2);
figure(1);
k = -54:0.01:54;
a3 = (sqrt(1-te^2) - (te^2) ./ (1./(delta*exp(i*(k*L + i*alpha*L)) - (t1^2)*exp(i*( (k*L + i*alpha*L) + (k*L1 + i*alpha*L1) ))./(1- (sqrt(1-t1^2))*exp(i*(k*L1 + i*alpha*L1)))) - sqrt(1-te^2)));
a3norm = abs(a3);
plot(k,a3norm, 'LineWidth',1)
axis([-54 54 0 0.9 ])
xlabel('unnormalized m')
ylabel('T')
%Get the indices corresponding to local minimas
idx = islocalmin(a3norm);
%To save them in an array, simply use logical indexing -
k_min = k(idx);
a3norm_min = a3norm(idx);
%Highlight the local minimas on the plot
hold on
plot(k_min,a3norm_min,'r*')

Plus de réponses (1)

L=1;
L1=L/6;
omega0 = 0;
omegaR = 10;
tR= (2*pi)/omegaR;
te = 0.8;
t1 = 0;
t_i = te/50;
gamma_i = 1;
%alpha = (t_i^2)/(2*L);
alpha = (2*pi*gamma_i)/(omegaR*L) ;
beta = sqrt(1-te^2);
delta = sqrt(1-t1^2);
syms k real
a3 = abs((sqrt(1-te^2) - (te^2) ./ (1./(delta*exp(i*(k*L + i*alpha*L)) - (t1^2)*exp(i*( (k*L + i*alpha*L) + (k*L1 + i*alpha*L1) ))./(1- (sqrt(1-t1^2))*exp(i*(k*L1 + i*alpha*L1)))) - sqrt(1-te^2))));
da3dk = diff(a3,k);
a3 = matlabFunction(a3);
da3dk = matlabFunction(da3dk);
k0 = -20*pi:2*pi:20*pi;
for i = 1:numel(k0)
kzero(i) = fzero(da3dk,[k0(i)-0.1 k0(i)+0.1]);
end
hold on
k = k0(1):0.01:k0(end);
%plot(k,da3dk(k))
%plot(kzero,da3dk(kzero),'o')
plot(k,a3(k))
plot(kzero,a3(kzero),'o')
hold off

Produits

Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by