Count the index of the array
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Mekala balaji
il 20 Dic 2014
Commentato: madhan ravi
il 3 Dic 2018
Hi, I have a array like below: [0 0 0 0 0 0 0 0 0 10 0 0 0 0 15 0 17]
I want count how many numbers >0 in the array (like in this case count is 3 (because 10,15,&17). Can some please help me how to count this in matlab. Thanks in advance
0 Commenti
Risposta accettata
Azzi Abdelmalek
il 20 Dic 2014
If your array doesn't contain negative numbers
a=[0 0 0 0 0 0 0 0 0 10 0 0 0 0 15 0 17]
out=nnz(a)
2 Commenti
Shoaibur Rahman
il 20 Dic 2014
nnz will count the number of all non-zero elements in the array, including negatives. So, this function would be a better choice if you want to do so.
Più risposte (2)
Vedere anche
Categorie
Scopri di più su Multidimensional Arrays in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!