Azzera filtri
Azzera filtri

Concatenate arrays horizontally n matrix by loop

3 visualizzazioni (ultimi 30 giorni)
Lila wagou
Lila wagou il 16 Ago 2016
Commentato: ZAHID RAZZAQ il 4 Mar 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

Risposte (1)

Thorsten
Thorsten il 16 Ago 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

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by