필터 지우기
필터 지우기

Repeat every element in matrix

조회 수: 2 (최근 30일)
Ahmed Hussein
Ahmed Hussein 2013년 6월 28일
Dears,
I have a matrix A(3200,3), I want to repeat each element (not repeat the matrix)in this matrix 200 times.
Thank you
  댓글 수: 2
per isakson
per isakson 2013년 6월 28일
row-wise or column-wise?
Ahmed Hussein
Ahmed Hussein 2013년 6월 28일
편집: Ahmed Hussein 2013년 6월 28일
A=[0 0 0 I want A to be A=[ 0 0 0 0 0 0 . 0 0 0 . . . . and so on to 200 times then the second element and so on.

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

채택된 답변

Roger Stafford
Roger Stafford 2013년 6월 28일
편집: Roger Stafford 2013년 6월 28일
A = reshape(repmat(A(:)',200,1),[],3);
This repeats the elements in the columns. If you want to repeat the along the rows do this:
A = reshape(repmat(reshape(A',[],1),1,200)',[],size(A,1))';
(Corrected)
  댓글 수: 4
Ahmed Hussein
Ahmed Hussein 2013년 6월 28일
Thanks a lot, it is very useful.....
Roger Stafford
Roger Stafford 2013년 6월 29일
That code I gave you has one more transpose than is necessary. You can do it this way instead:
A = reshape(repmat(reshape(A',1,[]),200,1),[],size(A,1))';

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by