haibaraxx的个人博客分享 http://blog.sciencenet.cn/u/haibaraxx

博文

Matlab: size and length of an array

已有 2299 次阅读 2016-8-22 21:48 |个人分类:Matlab|系统分类:科研笔记| and, size, array, length

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)).




https://wap.sciencenet.cn/blog-3031432-998031.html

上一篇:Matlab: read image
下一篇:Matlab: the colon operator :
收藏 IP: 134.1.1.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (2 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-1 17:24

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部