Interleave Vectors or Matrices

버전 1.1.0.0 (5.48 KB) 작성자: Steven Shimizu
Interleaves rows or columns of any number of vectors or matrices
다운로드 수: 1.5K
업데이트 날짜: 2014/3/5

라이선스 보기

A robust interleave function that interleaves any number of vectors or matrices by row or column. If the input are just vectors, there is no need to specify orientation. Extra elements/rows/columns are appended on the end of the output matrix. Not the most efficient algorithm, but it works well for most operations.

Examples:

1) Interleaving rows of matrices

A = [1 2; 3 4] B = [5 6;7 8]

C = interleave2(A, B, 'row')
C = [1 2
5 6
3 4
7 8]

2) Interleaving columns of matrices

C = interleave2(A, B, 'col')
C = [1 5 2 6
3 7 4 8]

3) Interleaving vectors (Note: input vectors need not be same orientation)

A = [1 2 3 4] B = [5 6 7 8 9]'
C = interleave2(A, B)
C = [1 5 2 6 3 7 4 8 9]'

4) Interleaving >2 matrices

A = [1 2;3 4] B = [5 6;7 8]
C = [9 10;11 12] D = [13 14;15 16]

E = interleave2(A, B, C, D, 'col')
E = [1 5 9 13 2 6 10 14
3 7 11 15 4 8 12 16]

5) Interleaving columns of 2 matrices with unequal columns

A = [1 2;3 4]
B = [5 6 7 8;9 10 11 12]
C = interleave2(A, B, 'col')
C = [1 5 2 6 7 8
3 9 4 10 11 12]

6) Interleaving >2 vectors of unequal lengths

A = [1 2 3 4] B = [5 6 7]
C = [8 9 10 11 12 13]
D = interleave2(A, B, C)
D = [1 5 8 2 6 9 3 7 10 4 11 12 13]

인용 양식

Steven Shimizu (2026). Interleave Vectors or Matrices (https://kr.mathworks.com/matlabcentral/fileexchange/45757-interleave-vectors-or-matrices), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2012a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Interleaving에 대해 자세히 알아보기
도움

도움 받은 파일: interleave

버전 게시됨 릴리스 정보
1.1.0.0

Modified description

1.0.0.0