MATLAB: How to use the “find” command to replace all values in a vector that meet a certain condition

find

I want to replace all values in vector V that are larger than 3 with a 3 using the "find" command.
V = [ 2 10 0 4 -2 7 -1 3 6 9 ]
Thanks for the help,
Erik

Best Answer

You don't need find function
v=[2 10 0 4 -2 7 -1 3 6 9]
v(v>3)=3
with find
v(find(v>3))=3