Problem 2991. Finding an element in a vector
x is a vector of unknown length
your function should return the index of the first element in the vector that is greater than 6. If all elements in x are less than 6, the function should return 'none'
example: x = [1 2 7 2 3 2 4 8 6]
output = 3
Solution Stats
Problem Comments
-
2 Comments
From a usability point of view, returning a string to indicate nothing found is probably the worst. an empty value or 0 would be much better.
Guillaume, I would say that that depends upon the intended 'audience' for the output.
Solution Comments
Show commentsProblem Recent Solvers188
Suggested Problems
-
Getting the indices from a vector
9799 Solvers
-
Generate N equally spaced intervals between -L and L
865 Solvers
-
Replace multiples of 5 with NaN
440 Solvers
-
Append two matrix as shown below example
225 Solvers
-
Replace every 3rd element in a vector with 4
249 Solvers
More from this Author28
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!