How to repeat a rectangular matrix in matlab?
古いコメントを表示
How to repeat a rectangular matrix in matlab?
Not using loops, just matlab's build-in commands.
Thanks a lot!

採用された回答
その他の回答 (2 件)
Azzi Abdelmalek
2014 年 7 月 24 日
編集済み: Azzi Abdelmalek
2014 年 7 月 24 日
A=[1 2 ; 3 4]
B=repmat(A,3,2)
3 件のコメント
Azzi Abdelmalek
2014 年 7 月 24 日
You didn't say anything about how do you want to shift your matrix? it's not just repeating a matrix.
rui
2014 年 7 月 24 日
Andrei Bobrov
2014 年 7 月 24 日
編集済み: Andrei Bobrov
2014 年 7 月 24 日
for your case:
t = zeros(6,2);
out = [kron(eye(3),a(:,1:2)),t]+[t,kron(eye(3),a(:,3:4))];
variant
m = 3;
k=2;
s = size(a);
n = (m-1)*k+s(2);
m1 = m*s(1);
out = zeros(m1,n);
t = sub2ind([m1,n],1:s(1):m1,1:k:k*m);
t2 = bsxfun(@plus,(0:s(2)-1)*m1,(0:s(1)-1)');
out(bsxfun(@plus,t,t2(:))) = a(:,:,ones(m,1));
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!