How can I replace non positive elements of matrix with a certain number

3 ビュー (過去 30 日間)
Lily
Lily 2015 年 5 月 16 日
コメント済み: Lily 2015 年 5 月 16 日
For example A=[7 4 2 1 -0.2 -3]
I want to get [7 4 2 0 0 ]

採用された回答

Walter Roberson
Walter Roberson 2015 年 5 月 16 日
max(A,0)
if the replacement is to be 0 for all values less than 0.
Otherwise,
B = A;
B(A<0) = new number
for any other replacement number

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by