I need to find elements of a vector that are less than one of more elements that come after it. It\'s easy to do in a loop:
x = some_vector_values;
for m = 1
If you would like to find elements that are less than some element to its right, you can do this also:
x = some_values'; % x should be a column vector to use this
h = hankel(x);
m = max(h,[],2);
f = find(x
The hankel matrix will show the elements to the right as it goes down the rows.
Then you can use the indices or true/false to iterate through a for loop and perform some operations. Here is an example:
x =
9
8
16
16
4
10
9
13
15
1
>> h = hankel(x)
h =
9 8 16 16 4 10 9 13 15 1
8 16 16 4 10 9 13 15 1 0
16 16 4 10 9 13 15 1 0 0
16 4 10 9 13 15 1 0 0 0
4 10 9 13 15 1 0 0 0 0
10 9 13 15 1 0 0 0 0 0
9 13 15 1 0 0 0 0 0 0
13 15 1 0 0 0 0 0 0 0
15 1 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
>> m = max(h,[],2)
m =
16
16
16
16
15
15
15
15
15
1
>> f = find(a