I need to find the length of an array for values > 0

1 Ansicht (letzte 30 Tage)
Cameron Bowyer
Cameron Bowyer am 12 Sep. 2021
Beantwortet: Chunru am 12 Sep. 2021
my array (called data) has values of 0 in it. I want to find the length of my array, exluding the 0 values.

Akzeptierte Antwort

Chunru
Chunru am 12 Sep. 2021
a = [1 2 0 3 -1 2 0];
n = sum(a~=0)
n = 5

Weitere Antworten (0)

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by