MATLAB ' : ' 官方解释

1.冒号的作用

   产生矢量,阵列标注以及for-loop迭代子

2.描述

    冒号是MATLAB中最有用的操作符之一。它使用下述规则来创建有规则的空间矢量:

j:k

is the same as [j,j+1,...,k], or empty when j > k.

j:i:k

is the same as [j,j+i,j+2i, ...,j+m*i], where m = fix((k-j)/i), for integer values. For information on the definition of j:i:k with floating-point values, see Technical Solution 1-4FLI96. This syntax returns an empty matrix when i == 0i > 0 and j > k, or i < 0 and j < k.

    如果你指定单标量阵列,MATLAB将j:i:k 解释为 j(1):i(1):k(1).

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

A(:,j)

is the jth column of A.

A(i,:)

is the ith row of A.

A(:,:)

is the equivalent two-dimensional array. For matrices this is the same as A.

A(:,j:k)

is A(:,j), A(:,j+1),...,A(:,k).

A(:,:,k)

is the kth page of three-dimensional array A.

A(i,j,k,:)

is a vector in four-dimensional array A. The vector includes A(i,j,k,1)A(i,j,k,2)A(i,j,k,3), and so on.

A(:)

is all the elements of A, regarded as a single column. On the left side of an assignment statement,A(:) fills A, preserving its shape from before. In this case, the right side must contain the same number of elements as A.

注:上述内容来自于MATLAB帮助文档

posted @ 2016-08-13 16:37  幻鼠  阅读(1358)  评论(0编辑  收藏  举报