Possible Duplicate:
Given a vector a=[1,2, 3.2, 4, 5] and an element x=3 In vector a, how to find the exact entry which is bigger than x?
Let's say a[] is a sorted vector. How do I find the first(smallest) index ix such that a(ix) > threshold?
You can use max() to get the max value. The max function can also return the index of the maximum value in the vector. To get this, assign the result of the call to max to a two element vector instead of just a single variable. Here, 7 is the largest number at the 4th position(index).
In MATLAB, indexes start at 1. Arrays can be sliced by using another array as an index.
In MATLAB the array indexing starts from 1. To find the index of the element in the array, you can use the find() function. Using the find() function you can find the indices and the element from the array. The find() function returns a vector containing the data.
Description. A >= B creates the condition greater than or equal. ge( A , B ) is equivalent to A >= B .
ix = find(a>threshold,1);
Pretty sure this will work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With