How do I insert one array into another?

7 Ansichten (letzte 30 Tage)
L'O.G.
L'O.G. am 25 Aug. 2022
Beantwortet: Chunru am 25 Aug. 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?

Akzeptierte Antwort

Chunru
Chunru am 25 Aug. 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

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by