Concatenate arrays horizontally n matrix by loop
3 次查看(过去 30 天)
显示 更早的评论
Please for a n matrix (with a same nbr of rows and columns), i want to Concatenate them horizontally by a loop,
A1 = [1 2 3; 2 4 6];
A2 = [4 5 6; 8 10 12];
A3 = [7 8 9; 14 16 18];
A4 = [10 11 12; 20 22 24];
AT = horzcat(A1,A2, A3, A4)
For n matrix i think to create a zero matrix and fill it by a loop
n=4
[mA1,nA1] = size(A1)
ATotal = zeros(mA1,nA1*n)
Please any help
0 个评论
回答(1 个)
Thorsten
2016-8-16
A(:,:,1) = [1 2 3; 2 4 6];
A(:,:,2) = [4 5 6; 8 10 12];
A(:,:,3) = [7 8 9; 14 16 18];
A(:,:,4) = [10 11 12; 20 22 24];
B = [];
for i=1:size(A,3)
B = [B, A(:,:,i)];
end
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!