필터 지우기
필터 지우기

mat2cell second input parameter(s)

조회 수: 1 (최근 30일)
Ahmed Hossam
Ahmed Hossam 2017년 4월 19일
댓글: Ahmed Hossam 2017년 4월 19일
Hier:
https://ch.mathworks.com/help/matlab/ref/mat2cell.html
I have a problem to fully understand the second, third, fourth and so on parameter for this Matlab function:
C = mat2cell(A,dim1Dist,...,dimNDist) divides array A into smaller arrays within cell array C. Vectors dim1Dist,...dimNDist specify how to divide the rows, columns, and (when applicable) higher dimensions of A.
Assume I have a (7 x 3) Matrix B. What's wrong of typing:
CellarrX = mat2cell(A,[1:2:7])
and meaning, that I'd like to have a CellarrX with:
(2 x 3) (2 x 3) (2 x 3) (1 x 3)
?!
If somebody has a good explanation for this, I'd be very thankful!

채택된 답변

KL
KL 2017년 4월 19일
편집: KL 2017년 4월 19일
Hi Ahmed,
From the example on the documentation, when you say
c = mat2cell(x, [10, 20, 30], [25, 25])
you should expect 'c' to have 6 (3*2) effective cell arrays. (3*2) comes from the size of the last two arguments in the above command. [10, 20, 30] specifies the number of rows in each resulting cell arrays and [25, 25] specifies columns. Now in your case you'd like to have 4 cell arrays but all of them have same number of columns. So the last two parameters should be of size 4 and 1.
X = rand(7,3)
C = mat2cell(X, [2 2 2 1], 3);
celldisp(C)
Now the last two parameters specify how you wanna distribute rows and columns respectively. Hope this was helpful. (the pictorial representation from the doc page helps you visualize the distribution quite easily.)
KL.
  댓글 수: 1
Ahmed Hossam
Ahmed Hossam 2017년 4월 19일
You're marvellous! Thanks!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Processing Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by