Removing zero values from an array
508 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Alice Stembridge
il 14 Mag 2015
Commentato: Stephen23
il 21 Mar 2022
I have an n x 1 array containing values. For exmaple A =
1
0
0
2
0
3
I was wondering if it was possible to create another array except without the zero values. For example
B =
1
2
3
1 Commento
Risposta accettata
Star Strider
il 14 Mag 2015
Using logical indexing, you can calculate ‘B’ in one line:
B = A(A~=0)
6 Commenti
Più risposte (0)
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!