The help files that come with Octave have the following entry:
19.1 Basic insert:
In a very good first approximation, the goal in vectorization is to write code that avoids loops and uses the operations of whole arrays. As a trivial example, consider
for i = 1:n for j = 1:m c(i,j) = a(i,j) + b(i,j); endfor endfor
compared to much simpler
c = a + b;
It is not just easier to write; also internally much easier to optimize. Octave delegates this operation to the main one, which, among other optimizations, can use a special vector of hardware instructions or, possibly, even complete additions parallel to each other. In the general case, if the code is vectorized, the implementation has more freedom with respect to the assumptions that it can make in order to speed up execution.
This is especially important for loops with "cheap" bodies. Often it is enough to vectorize only the innermost cycle to get an acceptable idea. The general rule is that the "order" of the vectorized body must be greater than or equal to the "order" of the closed loop.
As a less trivial example, instead of
for i = 1:n-1 a(i) = b(i+1) - b(i); endfor
records
a = b(2:n) - b(1:n-1);
This shows an important general concept of using arrays for instead of iterating over an index variable.  Index expressions. Also use boolean indexing generously. If the condition needs to be checked, this condition can also be written as a logical index. For example, instead of
for i = 1:n if (a(i) > 5) a(i) -= 20 endif endfor
records
a(a>5) -= 20;
which uses the fact that 'a> 5' creates a boolean index.
Use bitwise vector operators whenever possible to avoid a loop (operators such as '. *' And '. ^').  Arithmetic operations. For simple built-in functions, the “vectorization” function can do this automatically.
- Built-in function: vectorize (FUN) Create a vectorized version of the built-in FUN function, replacing all occurrences of ``, '/', etc. with '.', './', etc.
This may be useful, for example, when using inline functions with numerical integration or optimization where a vector-valued function is expected. fcn = vectorize (inline ("x^2 - 1")) => fcn = f(x) = x.^2 - 1 quadv (fcn, 0, 3) => 6 See also:  inline,  formula,  argnames.
Also use translation in these elementary statements as to avoid loops and unnecessary intermediate memory allocations.
 Broadcasting.
Use the built-in and library functions, if possible. Built-in and compiled functions are very fast. Even with the library function of m files, the likelihood that it is already optimized or will be optimized in a future release.
For example, even better than
a = b(2:n) - b(1:n-1);
is an
a = diff (b);
Most Octave functions are written using the arguments vector and array to the mind. If you find that you are writing a loop with a very simple operation, it is likely that such a function already exists. The following functions are often found in vectorized code:
Index manipulation
* find * sub2ind * ind2sub * sort * unique * lookup * ifelse / merge
Repetitions
* repmat * repelems
Vectorized Arithmetic
* sum * prod * cumsum * cumprod * sumsq * diff * dot * cummax * cummin
Large Array Shape
* reshape * resize * permute * squeeze * deal
Also look at these pages from the Stanford ML wiki for more detailed instructions with examples.
http://ufldl.stanford.edu/wiki/index.php/Vectorization
http://ufldl.stanford.edu/wiki/index.php/Logistic_Regression_Vectorization_Example
http://ufldl.stanford.edu/wiki/index.php/Neural_Network_Vectorization