Borrar filtros
Borrar filtros

Concatenate arrays horizontally n matrix by loop

3 visualizaciones (últimos 30 días)
Lila wagou
Lila wagou el 16 de Ag. de 2016
Comentada: ZAHID RAZZAQ el 4 de Mzo. de 2021
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

Respuestas (1)

Thorsten
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
halil ibrahim Gündüz
halil ibrahim Gündüz el 15 de Ag. de 2017
very good thnx bro.
ZAHID RAZZAQ
ZAHID RAZZAQ el 4 de Mzo. de 2021
Thanks for helping. It is very easy and useful

Iniciar sesión para comentar.

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!

Translated by