merge arrays into a new one with a specific element sequence

3 次查看(过去 30 天)
Hello,
Please help me with the following:
Consider two arrays, A=[a1;a2;a3] and B=[b1;b2;b3].
How can I get a new array C, where
C=[a1;b1;a2;b2;a3;b3] ?
This is an example for small arrays, I would be needing a code for any number of elements.
Thank you.
Best,
Pavlos

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2015-8-19
编辑:Azzi Abdelmalek 2015-8-19
A=[1; 2; 3]
B=[4 ;5; 6]
C=[A B]'
C=C(:)
Or
A=[1; 2; 3]
B=[4 ;5; 6]
C=reshape([A B]',[],1)
  3 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by