Replace array elemtens, that match the condition

1 次查看(过去 30 天)
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.

采纳的回答

Srikanth Sedimbi
Srikanth Sedimbi 2018-1-31
Try logical indexing
x(x<=10) = 0

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by