How do I insert one array into another?

6 visualizzazioni (ultimi 30 giorni)
L'O.G.
L'O.G. il 25 Ago 2022
Risposto: Chunru il 25 Ago 2022
I have two arrays with elements of type double. I want to insert the 1st column of array 2 after the 1st column of array 1, the 2nd column of array 2 after the 2nd column of array 1, and so on. How do I do this?

Risposta accettata

Chunru
Chunru il 25 Ago 2022
a = reshape(1:12, 3, 4)
a = 3×4
1 4 7 10 2 5 8 11 3 6 9 12
b = reshape(13:24, 3, 4)
b = 3×4
13 16 19 22 14 17 20 23 15 18 21 24
% You stack a and b, then reshape it
a = reshape([a; b], 3, 8)
a = 3×8
1 13 4 16 7 19 10 22 2 14 5 17 8 20 11 23 3 15 6 18 9 21 12 24

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by