MATLAB: Counting consecutive negative numbers in an array

arrayMATLAB

Hello, I need to find how many times consecutive negative numbers are in the array. For example:
v = [11 2 3 -1 -2 1 -1 -1 -3 1 3 -1];
The answer must be: 3
Thank you

Best Answer

length(strfind([false v<0],[0 1]))
or
sum(diff([false v<0])==1)