Jano Rajmond
Jano Rajmond

Reputation: 465

Concatenating 1D arrays into 2D arrays with several 1D array columns

I have 3 Matlab 1 coloumn arrays and I want to turn them into one 3 column array. How can I do this?

For example.

 A1 =     A2=    A3=

| 1 |   | 4 |   | 7 | 
| 2 |   | 5 |   | 8 |
| 3 |   | 6 |   | 9 |

I want the output to be:

Output = 

| 1 4 7 |
| 2 5 8 |
| 3 6 9 |

Thank you!

Found the answer, and it was very simple:

Output = [A1 A2 A3]

Thanks anyway!

Upvotes: 2

Views: 2609

Answers (1)

Anthony Blake
Anthony Blake

Reputation: 5348

B = horzcat(A1, horzcat(A2,A3))

Upvotes: 2

Related Questions