MATLAB: Negative number in vector

MATLABvector

say I have a vector v=[1 2 5 6 -8 5 2 7]
and I to create a new vector that has all the elements until the negative number shows up
such as c=[1 2 5 6]
how would you do this without using a while loop

Best Answer

c=v(1:find(v<0,1,'first')-1)