finding the minimums of function

1 visualización (últimos 30 días)
Nazar Tarlanli
Nazar Tarlanli el 12 de Dic. de 2018
Editada: madhan ravi el 12 de Dic. de 2018
Hello. On this plot you can notice 1 max and 2 min. How should I identify second min of my function? As you can see I found the real min, but there is a second min of function. I've tried but I'm getting only 1 value.
Capture.PNG
t = -10:0.1:-0.1;
t = t';
eta = zeros(size(t));
for i = 1:length(t)
eta(i,1) = 2 .* t(i,1) + 3 ./ t(i,1);
end
% % % max of function and time when it gets it's max
ind = find (eta == max(eta));
t_eta_max = t(ind ,1);
eta_max = eta (ind ,1);
% % % plot
plot(t,eta,'g-','linewidth',1.5);
hold on
plot ( t_eta_max , eta_max, 'marker','o','linewidth',1,'markeredgecolor','k','markerfacecolor','k','markersize',5);
grid on
xlim ([ -10 0]);
ylim ([ -30 0]);
% % % min of function and time when it gets it's min
ind = find (eta == min(eta));
t_eta_min = t(ind,1);
eta_min = eta (ind,1);

Respuestas (2)

madhan ravi
madhan ravi el 12 de Dic. de 2018
Editada: madhan ravi el 12 de Dic. de 2018
There’s only one local maxima which you have plotted , local minima doesn’t exist in the given domain
doc findpeaks
doc fminbnd

KSSV
KSSV el 12 de Dic. de 2018
Editada: KSSV el 12 de Dic. de 2018
Read about sort. Sort the required values into ascending order and pick the first two.
n = 20 ;
x = 1:n ;
y = rand(1,n) ;
[val,idx] = sort(y) ;
plot(x,y) ;
hold on
plot(x(idx(1:2)),y(idx(1:2)),'*r')

Categorías

Más información sobre Octave en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by