加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

MATLAB中的冒号(:)

(2012-03-21 07:37:30)
标签:

杂谈

分类: 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 == 0, i > 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帮助文档

0

阅读 收藏 喜欢 打印举报/Report
前一篇:QVGA
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有