size函数

来源:互联网 发布:mac 升级10.8 编辑:程序博客网 时间:2024/05/16 08:32

size 

Array dimensions

阵列维度

Syntax

语法

d = size(X)

[m,n] = size(X)

m = size(X,dim)

[d1,d2,d3,...,dn] = size(X)

Description

描述

d = size(X) returns the sizes of each dimension of array X in a vector d with ndims(X) elements.

d=size(X) 在一个带有ndims(X)元素的向量d中,返回阵列X的每个维度的尺寸。

[m,n] = size(X) returns the size of matrix X in separate variables m and n.

[m,n]=size(X) 在区分的变量mn中,返回矩阵X的尺寸。

m = size(X,dim) returns the size of the dimension of X specified by scalar dim.

m=size(X,dim) 通过标定dim值返回X特定的维度的尺寸。

[d1,d2,d3,...,dn] = size(X) returns the sizes of the first n dimensions of array X in separate variables. 

[d1,d2,d3,...,dn]=size(X) 在区分的变量中,返回阵列X的第一个n维的尺寸

If the number of output arguments n does not equal ndims(X), then for:

如果输出的数值n不等于ndims(X),那么:

n > ndims(X) size returns ones in the "extra" variables, i.e., outputs ndims(X)+1 through n.

n>ndims(X) 尺寸在"extra"变量中返回一次 ,i.e.,通过n输出ndims(X)+1 

n < ndims(X) dn contains the product of the sizes of the remaining dimensions of X, i.e., dimensions n+1 through ndims(X).

n<ndims(X) dn 包含X的剩余维度的尺寸的结果,i.e.,维度n+1通过ndims(X)

Note    For a Java array, size returns the length of the Java array as the number of rows. The number of columns is always 1. For a Java array of arrays, the result describes only the top level array. 

Examples

注意:一个Java 阵列,size 返回Java 阵列的长度作为列的数值。行的数值通常为1.一个阵列中的Java阵列,结果描述仅仅顶级水平阵列。

Example 1. The size of the second dimension of rand(2,3,4) is 3.

例如1.rand(2,3,4)的第二维度的尺寸是3

m = size(rand(2,3,4),2)

m =

     3

Here the size is output as a single vector.

这里size输出为一个单精度向量。

d = size(rand(2,3,4))

d =

     2     3     4

Here the size of each dimension is assigned to a separate variable.

这里每个维度的尺寸是分配到一个区分的变量中。

[m,n,p] = size(rand(2,3,4))

m =

     2

n =

     3

p =

     4

Example 2. If X = ones(3,4,5), then

例如2.如果X=ones(3,4,5),则

[d1,d2,d3] = size(X)

d1 =       d2 =       d3 =

     3          4          5

But when the number of output variables is less than ndims(X):

而当输出变量的数值是小于ndims(X)

[d1,d2] = size(X)

d1 =       d2 =

     3          20

The "extra" dimensions are collapsed into a single product. 

"extra"维度是倒塌进一个单精度结果。

If n > ndims(X), the "extra" variables all represent singleton dimensions:

如果n>ndims(X)"extra"变量所有表示单精度维度:

[d1,d2,d3,d4,d5,d6] = size(X)

d1 =       d2 =       d3 =

     3          4          5

d4 =       d5 =       d6 =

     1          1          1

原创粉丝点击