Logical Indexing Is Gold
Instead of looping with if-statements, use logical indexing:
A(A < 0) = 0;
One line, no loops, full clarity.
1 Kommentar
Zeit (absteigend)For the given example MAX() will often be more efficient:
A = max(A,0);
Anmelden, um teilzunehmen