Matlab-colon (:)

2015-04-16  本文已影响20人  六便士少年

colon (:)

Create vectors, array subscripting, and for loop iterations

DescriptionThe

colon is one of the most useful operators in MATLAB. It can create vectors, subscript arrays, and specify for iterations.
The colon operator uses the following rules to create regularly spaced vectors:

j:k is the same as [j,j+1,...,k]
j:k is empty if j > k
j:i:k is the same as [j,j+i,j+2i, ...,k]
j:i:k is empty if i > 0 and j > k or if i < 0 and j < k

where 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 higher-dimensional arrays:

上一篇下一篇

猜你喜欢

热点阅读