Rounding-off zero to negative
조회 수: 5 (최근 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!