필터 지우기
필터 지우기

Permute my center blocks

조회 수: 2 (최근 30일)
Yuxing Zhang
Yuxing Zhang 2018년 11월 6일
댓글: Bruno Luong 2018년 11월 6일
I have a matrix A with center piece (80×80) and I have now divided into 16 blocks of size 20×20. I also have a permutation vector V=[7 11 2 3 ....], which I need to place the 7th block in the location of the first block, place the 11th block in the location of the second block, etc.
Now the issue is I don't know how make make my blocks into numbered blocks and change order, can any one give me some example codes?
below this my code:
A=rand(200,200);
Acenter=A(161:240,161:240);
Ablock= mat2cell(Acenter,[20 20 20 20 ],[20 20 20 20]);
  댓글 수: 1
Bruno Luong
Bruno Luong 2018년 11월 6일
Acenter=A(161:240,161:240)
What is that for, beside just throw out an error because the indexing is wrong?
What is the relation of block permutation?

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

채택된 답변

per isakson
per isakson 2018년 11월 6일
편집: per isakson 2018년 11월 6일
"how make make my blocks into numbered blocks" Matlab does that automatically, e.g.
>> Ablock(11)
ans =
1×1 cell array
{20×20 double}
See Array Indexing, and notice "linear indexing"
Check whether this does the trick
A=rand(200,200);
Acenter=A(61:140,61:140);
Ablock= mat2cell(Acenter,[20 20 20 20 ],[20 20 20 20]);
V = randperm(16); % random permutation vector
Bblock = reshape( Ablock(V), size(Ablock) );

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by