Effacer les filtres
Effacer les filtres

Rounding-off zero to negative

6 vues (au cours des 30 derniers jours)
Khawaja Asim
Khawaja Asim le 16 Août 2011
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

Réponse acceptée

Oleg Komarov
Oleg Komarov le 16 Août 2011
% Random input
A = randn(10,1);
% Index negative values
idx = A < 0;
% Substitute them with zero
A(idx) = 0;

Plus de réponses (1)

Walter Roberson
Walter Roberson le 16 Août 2011
A = max(A,0);
But cross-check whether this gives you the behaviour you want for NaN.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by