How to merge first elements from 2 array into an new array?
Informazioni
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Mostra commenti meno recenti
Hi,
I want to merge 2 arrays so that the output is as follows:
A=[1 2 3]
B=[4 5 6]
I want C to be:
C=[1 4 2 5 3 6]
That pick up each successive numbers from each side and place them side by side in a new array? Any way of doing this using simple lines ..if possible no use of inbuilt functions..
1 Commento
yashvin
il 30 Giu 2015
Risposte (2)
Azzi Abdelmalek
il 30 Giu 2015
C=reshape([A;B],1,[])
3 Commenti
yashvin
il 30 Giu 2015
Azzi Abdelmalek
il 30 Giu 2015
Modificato: Azzi Abdelmalek
il 30 Giu 2015
C=[A;B]
C=C(:)'
Azzi Abdelmalek
il 30 Giu 2015
Or
A=[1 2 3]
B=[4 5 6]
n=numel(A)
C(1:2:2*n)=A;
C(2:2:2*n)=B;
Andrei Bobrov
il 30 Giu 2015
AB = [A;B];
out = AB(:)';
Questa domanda è chiusa.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!