필터 지우기
필터 지우기

How can I index these matrix blocks into numbers?

조회 수: 1 (최근 30일)
Yuxing Zhang
Yuxing Zhang 2018년 11월 6일
댓글: Yuxing Zhang 2018년 11월 6일
I have a 80×80 matrix A and divide it into 16 blocks of size 20x20, by
A=rand(80,80);
C= mat2cell(A,[20 20 20 20 ],[20 20 20 20]);
And I want to index these blocks in order from 1 to 16 like the figure shows, how can I do this?
Any help will be excellent!

채택된 답변

Stephen23
Stephen23 2018년 11월 6일
편집: Stephen23 2018년 11월 6일
Actually you can already access it like you want, using linear indexing. Try it:
C{1}
C{2}
...
C{16}
Here is a demonstration using the second-to-last cell, C{15}:
>> A = rand(80,80);
>> C = mat2cell(A,[20,20,20,20],[20,20,20,20]);
>> isequal(C{15},A(41:60,61:80))
ans = 1
  댓글 수: 2
Stephen23
Stephen23 2018년 11월 6일
If this is related to your earlier question:
Then all you need is this:
C = mat2cell(...)
C(:) = C(V);
new = cell2mat(C)
Yuxing Zhang
Yuxing Zhang 2018년 11월 6일
yeah, I do get, thank you.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by