Concatinate the ith element of one matrix with the ith element of second matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
I have two matrices and i want to concatinate the 1st element of fist matrix with the first element of second matrix and so on (i'th with i'th)
Below are the arbitrary matrices (can be bigger but with same dimensions)
a=[1 2 3 4 5 6];
b=[10 11 12 13 14 15];
How can i get the result matrix?
result=[1 10 2 11 3 12 4 13 5 14 6 15];
댓글 수: 0
채택된 답변
madhan ravi
2019년 2월 25일
편집: madhan ravi
2019년 2월 25일
"Below are the arbitrary matrices (can be bigger but with same dimensions)"
result=reshape([a(:) b(:)].',1,[])
댓글 수: 2
추가 답변 (1개)
Jan
2019년 2월 25일
Alternative:
a = [1 2 3 4 5 6];
b = [10 11 12 13 14 15];
c = zeros(1, numel(a) + numel(b));
c(1:2:end) = a;
c(2:2:end) = b;
댓글 수: 1
Jan
2019년 4월 29일
@ARN: I answer a question, if I find the time to do this and if I have some potentially useful ideas about the question. It is considered to be impolite to push others to answer questions. Imagine how much noise you would find in the forum, if anybody advertises his or her questions in the section for comments of other threads. So please don't do this.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!