Rounding-off zero to negative
6 ビュー (過去 30 日間)
古いコメントを表示
Is there any built-in function in matlab that takes all the negative values equal to zero? or round off negative values to zero? Regards
0 件のコメント
採用された回答
Oleg Komarov
2011 年 8 月 16 日
% Random input
A = randn(10,1);
% Index negative values
idx = A < 0;
% Substitute them with zero
A(idx) = 0;
0 件のコメント
その他の回答 (1 件)
Walter Roberson
2011 年 8 月 16 日
A = max(A,0);
But cross-check whether this gives you the behaviour you want for NaN.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!