If you know that it's 1-dimensional, you can use
which returns the length of your vector. Also useful to know is
which returns the size of a matrix (eg, [2 2] for a 2x2 matrix, [10 1] for a 10x1 vector, etc).
Edit I've replaced length with numel - thank you Rik.