How to calculate the mean value of the non vero value in a vector?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
How to calculate the mean value of the non vero value in a vector?
For example there is a vector contains 3 values M = [0.7,0.3,0]
the mean value in this case should be 0.5
0 Commenti
Risposta accettata
Più risposte (1)
James Tursa
il 3 Set 2022
Modificato: James Tursa
il 3 Set 2022
Another way that doesn't require any data copying:
M = [0.7,0.3,0];
sum(M)/nnz(M)
Be aware that if there are no non-zero elements, this will return NaN (same as Star's method).
0 Commenti
Vedere anche
Categorie
Scopri di più su Error Functions 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!