Transform a two dimensional into a three dimensional and combine with another three dimensional array

1 回表示 (過去 30 日間)
Hi, I have this matrix
A=randn(4,3);
and I want to transform it in a three dimensional matrix by stacking that matrix 5 times (without using repmat). Then, I want to horizontally combine that matrix with the matrix
B=zeros(4,10,5)
Could you help me? Thanks a lot!

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 1 日
A=randn(4,3)
out=[A(:,:,ones(1,5)) zeros(4,10,5)]

その他の回答 (1 件)

Iain
Iain 2013 年 11 月 1 日
Repmat is an efficient method...
A = randn(4,3);
for i = 5:-1:1
B(:,:,5) = A;
end
B(:,end+(1:10),:) = zeros(4,10,5);

カテゴリ

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