필터 지우기
필터 지우기

Rounding-off zero to negative

조회 수: 6 (최근 30일)
Khawaja Asim
Khawaja Asim 2011년 8월 16일
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

채택된 답변

Oleg Komarov
Oleg Komarov 2011년 8월 16일
% Random input
A = randn(10,1);
% Index negative values
idx = A < 0;
% Substitute them with zero
A(idx) = 0;

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 8월 16일
A = max(A,0);
But cross-check whether this gives you the behaviour you want for NaN.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by