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

Stephen23
Stephen23 2015년 9월 7일
편집: Stephen23 2020년 10월 15일

2 개 추천

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)
You might like to read about multidimensional arrays to know how these are defined and accessed.
For the new data class tables you can use the width function to get how many variables there are in the table, and height to get the number of rows of the table.

댓글 수: 3

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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

질문:

2015년 9월 7일

편집:

2020년 10월 15일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by