|||
X=1;
Y=[2 3 4];
Z=[1 5;2 6;3 7];
E=[] % an empty matrix
% size returns a row vector describing the dimensions of an array.
sz_X=size(X);
-> 1 1 % [1 1] 1 row, 1 column
sz_Y=size(Y);
-> 1 3 % [1 3] 1 row, 3 column
sz_Z=size(Z);
-> 3 2 % [3 2] 3 row, 2 column
sz_Z=size(E);
-> 0 0 % [0 0]
% length returns a scalar describing the largest dimension of an array.
len_X=length(X);
-> 1
len_Y=length(Y);
-> 3 % For vectors, the length is simply the number of the elements.
len_Z=length(Z);
-> 3 % For arrays with more dimensions, length(Z) is max(size(Z)).
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-6-1 17:14
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社