Replace array elemtens, that match the condition

1 回表示 (過去 30 日間)
Alexander Donner
Alexander Donner 2018 年 1 月 28 日
コメント済み: Alexander Donner 2018 年 2 月 1 日
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
  1 件のコメント
Alexander Donner
Alexander Donner 2018 年 2 月 1 日
yup, that did it. Thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by