Please help me. I want to find the first null element in an array in matlab. I use the find function to find zero, but it did not give a true answer, but it gives the correct answer for 1. so please help me as soon as possible.
find should do the trick if used like this:
find
> a = [1 2 3 0 5 6 0 8 9]; > find(a==0, 1, 'first') ans = 4
Let us know if this does not work (and some additional information 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
more simple:
find(~a,1,'first')