Rounding-off zero to negative
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Oleg Komarov
il 16 Ago 2011
% Random input
A = randn(10,1);
% Index negative values
idx = A < 0;
% Substitute them with zero
A(idx) = 0;
0 Commenti
Più risposte (1)
Walter Roberson
il 16 Ago 2011
A = max(A,0);
But cross-check whether this gives you the behaviour you want for NaN.
0 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!