how can enlarge a matrix?

조회 수: 10 (최근 30일)
jack nn
jack nn 2015년 6월 3일
댓글: jack nn 2015년 6월 4일
hi I have some matrixes that I want to resize these in a way that every element repeated in a 5*5 Square for example: m=[1,2;3,4] and I want to my result be this:
1 1 1 1 1 2 2 2 2 2
1 1 1 1 1 2 2 2 2 2
1 1 1 1 1 2 2 2 2 2
1 1 1 1 1 2 2 2 2 2
1 1 1 1 1 2 2 2 2 2
3 3 3 3 3 4 4 4 4 4
3 3 3 3 3 4 4 4 4 4
3 3 3 3 3 4 4 4 4 4
3 3 3 3 3 4 4 4 4 4
3 3 3 3 3 4 4 4 4 4
..... I searched but imresize and reshape can not do this for me.Is there any way?

채택된 답변

Stephen23
Stephen23 2015년 6월 3일
편집: Stephen23 2015년 6월 3일
If you have MATLAB R2015a (or more recent) then you can use repelem.
Otherwise you could try this FEX submission:
Or else you have to calculate it yourself, the easiest way is to use kron:
>> m = [1,2;3,4];
>> n = 5;
>> kron(m,ones(n))
ans =
1 1 1 1 1 2 2 2 2 2
1 1 1 1 1 2 2 2 2 2
1 1 1 1 1 2 2 2 2 2
1 1 1 1 1 2 2 2 2 2
1 1 1 1 1 2 2 2 2 2
3 3 3 3 3 4 4 4 4 4
3 3 3 3 3 4 4 4 4 4
3 3 3 3 3 4 4 4 4 4
3 3 3 3 3 4 4 4 4 4
3 3 3 3 3 4 4 4 4 4
  댓글 수: 1
jack nn
jack nn 2015년 6월 4일
thanks Stephen Cobeldick.

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

추가 답변 (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