Matrix conversion
조회 수: 1 (최근 30일)
이전 댓글 표시
how to get a matrix of the form from a given matrix, for exapmle
a= [2 3 4
5 6 7
8 9 0]
i want a matrix where in each elements are repeated in other matrix as follows
b= [2 2 3 3 4 4
2 2 3 3 4 4
5 5 6 6 7 7
5 5 6 6 7 7
8 8 9 9 0 0
8 8 9 9 0 0]
댓글 수: 0
채택된 답변
Chandra Kurniawan
2012년 1월 11일
I= [2 3 4;
5 6 7;
8 9 0];
[m n] = size(I);
ShX = 2;
ShY = 2;
r = m*ShX;
c = n*ShY;
J = zeros(r,c);
for x = 1 : m
for y = 1 : n
J((x-1)*ShX+1 : x*ShX, (y-1)*ShY+1 : y*ShY) = I(x,y);
end
end
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!