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.
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
>> a = [1 2 3 0 5 6 0 8 9];
>> a=a==0;
>> n=1:length(a);
>> [n out]=max(a./n);
out =
4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With