Interleaved repmat (row duplication)
6 ビュー (過去 30 日間)
古いコメントを表示
I would like to do a specific repmat such that if I have:
a=[1 0 0;0 0 1;1 1 1]
I would like to duplicate each row by a value N, so that in the case N = 2 each row will be duplicated twice:
b=[1 0 0;1 0 0;0 0 1;0 0 1;1 1 1;1 1 1]
Is there an easy way of doing this interleaved repmat? Thanks
0 件のコメント
採用された回答
Stephen23
2021 年 11 月 5 日
The simple and efficient approach is to use REPELEM:
a = [1,0,0;0,0,1;1,1,1]
b = repelem(a,2,1)
その他の回答 (1 件)
Sudharsana Iyengar
2021 年 11 月 5 日
Try this
A=[1,0,0; 0 0 1; 1 1 1;];
k=1;
for i =1:3
T(k:k+1,:)=repmat(A(i,:),2,1);
k=k+2;
end
T
0 件のコメント
参考
カテゴリ
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!