-
Notifications
You must be signed in to change notification settings - Fork 8
/
find_second_min.m
48 lines (44 loc) · 1.09 KB
/
find_second_min.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function [second_min , val]= find_second_min(A, i)
% This functions finds the second minima in a smooth fit polynomial
% start searching from the ith index
%
%
% Input-
% A: a vector of values
% i: the value to start searching for the second minima
%
%
% Author: Mohammed Al-Rawi [[email protected]]
% Project: SWARMs
% Date: Sept 12, 2016
%
%
%
% License:
%=====================================================================
% This is part of the UNDROIP toolbox, released under
% the GPL. https://github.com/rawi707/UNDROIP/blob/master/LICENSE
%
% The UNDROIP toolbox is available free and
% unsupported to those who might find it useful. We do not
% take any responsibility whatsoever for any problems that
% you have related to the use of the UNDROIP toolbox.
%
% ======================================================================
%%
while(1)
if A(i+1)>A(i)
i=i+1;
continue;
else break;
end
end
while(1)
if A(i+1)<A(i)
i=i+1;
continue;
else break;
end
end
second_min=i;
val = A(second_min);