Concatenate arrays horizontally n matrix by loop
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Thorsten
el 16 de Ag. de 2016
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 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!