MATLAB Functions  Help Desk 
for
iterations.
The colon operator uses the following rules to create regularly spaced vectors:j:k


j:k


j:i:k


j:i:k

i
,j
, and k
are all scalars.
Below are the definitions that govern the use of the colon to pick out selected rows, columns, and elements of vectors, matrices, and higherdimensional arrays:D = 1:4results in
D = 1 2 3 4Using two colons to create a vector with arbitrary real increments between the elements,
E = 0:.1:.5results in
E = 0 0.1000 0.2000 0.3000 0.4000 0.5000The command
A(:,:,2) = pascal(3)generates a threedimensional array whose first page is all zeros.
A(:,:,1) = 0 0 0 0 0 0 0 0 0 A(:,:,2) = 1 1 1 1 2 3 1 3 6
for
Repeat statements a specific number of times
linspace
Generate linearly spaced vectors
logspace
Generate logarithmically spaced vectors
reshape
Reshape array