Is there a built-in function that retrieves non-zero values ​​in MATLAB?

I was wondering if there is a function like the one below (less), but instead retrieves values ​​that are not non-zero?

a = [67 0 8 25 0 20 0 90 7 2 9];

smaller10 = a(a < 10)

smaller10 =

 0     8     0     0     7     2     9
+4
source share
1 answer

Use

a(a~=0)

or

nonzeros(a).'

You can find the documentation for nonzeros here .

+3
source

Source: https://habr.com/ru/post/1628023/


All Articles