Divide and expand matrix
이전 댓글 표시
I have a 600x600 matrix with integer values in each cell. What I want to do is expand that matrix into a 6,000x6,000 matrix. However, since it is being expanded to 10x its size, I need to scale the integer in each cell accordingly. So if I have the value 10 in row 1 column 1 of the 600x600 matrix, I now need the value 1 in rows 1-10 columns1-10. Does anyone have any ideas how to do this?
댓글 수: 2
Geoff Hayes
2017년 7월 7일
Andrew - what happens if the value in row 1 column 1 (or any other position) is not divisible by ten? (Since you are saying that the value 10 at (1,1) must be 1 in (1:10,1:10).)
Andrew Poissant
2017년 7월 7일
채택된 답변
추가 답변 (1개)
Geoff Hayes
2017년 7월 7일
Andrew - what have you tried so far? Suppose mtx1 is your 600x600 matrix and mtx2 is your 6000x6000 matrix. The mapping of your elements from mtx1 to mtx2 is as follows
mtx1(1,1) --> mtx2(1:10,1:10)
mtx1(1,2) --> mtx2(1:10, 11:20)
mtx1(1,3) --> mtx2(1:10,21:30)
...
mtx1(2,1) --> mtx2(11:20,1:10)
...
mtx1(3,1) -->mtx2(21:30,1:10)
So one way to do this, is to iterate over each row and column of mtx1 and then map it to the correct "block" of mtx2 probably something like
mtx2((r-1)*10+1:r*10,(c-1)*10+1:c*10) = mtx1(u,v)/10;
where r and c are the indices to the current row and column respectively.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!