How to merge first elements from 2 array into an new array?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
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
yashvin
2015년 6월 30일
답변 (2개)
Azzi Abdelmalek
2015년 6월 30일
C=reshape([A;B],1,[])
댓글 수: 3
yashvin
2015년 6월 30일
Azzi Abdelmalek
2015년 6월 30일
편집: Azzi Abdelmalek
2015년 6월 30일
C=[A;B]
C=C(:)'
Azzi Abdelmalek
2015년 6월 30일
Or
A=[1 2 3]
B=[4 5 6]
n=numel(A)
C(1:2:2*n)=A;
C(2:2:2*n)=B;
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!