Find first zero in array in matlab

matlab

Solution

`find` should do the trick if used like so:

> a = [1 2 3 0 5 6 0 8 9];
> find(a==0, 1, 'first')
ans =  4

Let us know if this isn't working (and some additional details about the problem).

MATLAB find

Problem

I want to find first zero element in array in matlab. I'm using "find" function to find zero but it didn't giving true answer but it give correct answer for 1.

Original source