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

4 views (last 30 days)
my array (called data) has values of 0 in it. I want to find the length of my array, exluding the 0 values.

Accepted Answer

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

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by