simple way of matrix array resorting

1 Ansicht (letzte 30 Tage)
Hyun-su Kim
Hyun-su Kim am 12 Dez. 2019
Kommentiert: Hyun-su Kim am 12 Dez. 2019
I have three matrix, A, B, and C.
A = [a1 a2 a3 ...], B = [b1 b2 b3 ...], C = [c1 c2 c3 ...]
I want to create a matrix Q which look like
a1 b1 c1
a2 b2 c2
a3 b3 c3
...
What's simplist code?
Thank you.

Akzeptierte Antwort

Stephen23
Stephen23 am 12 Dez. 2019
Robust:
Q = [A(:),B(:),C(:)]

Weitere Antworten (2)

Guillaume
Guillaume am 12 Dez. 2019
Assuming your 3 vectors are row vectors (i.e. 1xN), then
result = [A; B; C].' %vertically concatenate then transpose

Adam
Adam am 12 Dez. 2019
Q = [A', B', C'];

Kategorien

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

Community Treasure Hunt

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

Start Hunting!

Translated by