Modifying a matrix such that each entry can be written in a block of four
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I have a matrix, say
A = [1 2
3 4];
I want to modify it in such a way that it can be written as
A = [1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4];
Each entry in the matrix A can be written in a block of four. How can I code it?
댓글 수: 0
채택된 답변
Walter Roberson
2021년 9월 6일
편집: Walter Roberson
2021년 9월 6일
A = [1 2
3 4]
B = kron(A, ones(2,2))
C = repelem(A, 2, 2)
댓글 수: 0
추가 답변 (1개)
Yamina chbak
2021년 9월 6일
a=[1 2 ; 3 4];
A=zeros(2*size(a));
A(1:2,1:2)=a(1);
A(1:2,3:4)=a(3);
A(3:4,1:2)=a(2);
A(3:4,3:4)=a(4);
A
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!