フィルターのクリア

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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by