Width function on arrays
显示 更早的评论
How do i use the width or height functions on a 3d array? For example, the array information i am using is that of a picture.
回答(1 个)
MATLAB does not have width or height functions for normal arrays. You can use size to get the size of an array:
d = size(X)
[m,n,p,~] = size(X)
m = size(X,dim)
You can select the dimension using the optional second argument:
rows = size(X,1)
cols = size(X,2)
pages = size(X,3)
3 个评论
Walter Roberson
2015-9-7
Caution: if X is 3 or more dimension, then
[m,n] = size(X)
will return unexpected values in "n"! Be sure to read the documentation for size() for what it does when there are multiple outputs.
f
2020-10-15
Just for future reference: as of R2020b, I think width and height have been added for arrays: https://it.mathworks.com/help/matlab/ref/width.html?s_tid=srchtitle
Indeed, just added to the latest release: https://www.mathworks.com/matlabcentral/discussions/highlights/133276-new-in-r2020b-new-way-to-return-height-or-width-of-arrays
类别
在 帮助中心 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!