Colon notation


>> The colon( : ) is one of the most useful operator in MATLAB. It is used to create vectors, subscript arrays, and specify for iterations. If you want to create a row vector, containing integers from 1 to 10, you write:




If you want to specify an increment value other than one, for example:




You can use the colon operator to create a vector of indices to select rows, columns or elements of arrays.


Try this example yourself:



0:pi/8:pi

ans = .........?


The following picture describes its use for this purpose (let us we have a matrix A):




Example: