MATLAB: Replace array elemtens, that match the condition

for loopif statement

Hey guys,
I have an array with x= 1:1:100; and i want to replace every element that is <= than 10 with 0.
My thought was to us the "if" function under an "for" loop, but i dont realy know how to do that.
i hope you guys can help me with that.
Thanks in advance.

Best Answer

Try logical indexing
x(x<=10) = 0