matlab—size用法
来源:互联网 发布:数据库百科 编辑:程序博客网 时间:2024/06/10 01:48
size(A)函数是用来求矩阵的大小的,你必须首先弄清楚A到底是什么,大小是多少。
比如说一个A是一个3×4的二维矩阵:
1、size(A) %直接显示出A大小
输出:ans=
3 4
2、s=size(A)%返回一个行向量s,s的第一个元素是矩阵的行数,第二个元素是矩阵的列数
输出:s=
3 4
3、[r,c]=size(A)%将矩阵A的行数返回到第一个输出变量r,将矩阵的列数返回到第二个输出变量c
输出:r=
3
c=
4
4、[r,c,m]=size(A)
输出:r=
3
c=
4
m=
1
也就说它把二维矩阵当作第三维为1的三维矩阵,这也如同我们把n维列向量当作n×1的矩阵一样
5、当a是一个n维行向量时,size(A)把其当成一个1×n的矩阵,因此size(a)的结果是
ans
1 n
而不是a的元素个数n
6、size(A,n)
如果在size函数的输入参数中再添加一项n,并用1或2为n赋值,则 size将返回矩阵的行数或列数。其中r=size(A,1)该语句返回的是矩阵A的行数, c=size(A,2) 该语句返回的是矩阵A的列数。
matlab中的解释如下:
Syntax
d = size(X)
[m,n] = size(X)
m = size(X,dim)
[d1,d2,d3,...,dn] = size(X),
Description
d = size(X) returns thesizes of each dimension of arrayX in a vector d with ndims(X) elements.If X is a scalar, which MATLAB software regardsas a 1-by-1 array,size(X) returns the vector [11].
[m,n] = size(X) returnsthesize of matrix X in separate variablesm and n.
m = size(X,dim) returnsthesize of the dimension of X specified by scalardim.
[d1,d2,d3,...,dn] = size(X), for n >1, returns the sizes of the dimensions of the arrayX inthe variables d1,d2,d3,...,dn, provided the number of output argumentsn equals ndims(X).If n does not equal ndims(X),the following exceptions hold:
n < ndims(X)
di equals the size of the ithdimension of X for , butdn equalsthe product of the sizes of the remaining dimensions of X, thatis, dimensionsn through ndims(X).
n > ndims(X)
size returns ones in the "extra"variables, that is, those corresponding tondims(X)+1 through n.
Note For a Java array, size returns the lengthof the Java array as the number of rows. The number of columns isalways 1. For a Java array of arrays, the result describes only thetop level array.
Examples
Example 1
The size of the second dimension of rand(2,3,4) is3.
m = size(rand(2,3,4),2)m = 3
Here the size is output as a single vector.
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 = 2n = 3p = 4
Example 2
If X = ones(3,4,5), then
[d1,d2,d3] = size(X)d1 = d2 = d3 = 3 4 5
But when the number of output variables is less than ndims(X):
[d1,d2] = size(X)d1 = d2 = 3 20
The "extra" dimensions are collapsed into a singleproduct.
If n > ndims(X), the "extra"variables all represent singleton dimensions:
[d1,d2,d3,d4,d5,d6] = size(X)d1 = d2 = d3 = 3 4 5d4 = d5 = d6 = 1 1 1
- matlab—size用法
- matlab—size用法总结
- matlab中size的用法
- Matlab中size函数用法
- matlab中size()的用法
- MATLAB中Size的用法
- matlab中size/length/numel的用法
- matlab中size()函数的用法
- matlab中size()函数的用法
- matlab中size/length/numel的用法
- matlab中size/length/numel的用法
- matlab中size()函数的用法
- matlab中size()函数的用法
- MATLAB中size函数的用法
- matlab中size()函数的用法
- matlab中size()函数的用法
- Matlab中size函数的用法
- matlab中size()函数的用法
- Using Web Server Plug-Ins with WebLogic Server
- Oracle-03
- 谷歌三大核心技术(二)Google MapReduce中文版
- 一个高级的Android启动画面
- mkv中cluster位置的计算
- matlab—size用法
- JNI引用与垃圾回收
- Memcached之内存利用率提升经验分享
- 快速排序、堆排序、希尔排序实现
- 【心灵鸡汤】@2012-06-15
- 自我学习
- memset函数的性质
- CEGUI控件随着窗口大小改变而改变
- 四六级考前最后一天必须重温的100个词汇