Create matrix with two matrices
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello, I have two matrices that I want to combine to form another one as in the example below:
A = [1 2 3; 4 5 6;7 8 9]
B = [ 11 12 13;14 15 16;17 18 19]
Matrix = [1 2 3 ; 11 12 13 ; 4 5 6 ; 14 15 16 ; 7 8 9 ; 17 18 19]
Can anyone help me to solve it?
Many thanks,
Eva
댓글 수: 0
답변 (2개)
KSSV
2020년 11월 27일
A = [1 2 3; 4 5 6;7 8 9]
B = [ 11 12 13;14 15 16;17 18 19]
m = size(A,1)+size(B,2) ;
C = zeros(m,3) ;
C(1:2:end,:) = A ;
C(2:2:end,:) = B ;
댓글 수: 0
Ameer Hamza
2020년 11월 27일
편집: Ameer Hamza
2020년 11월 27일
You can do something like this
A = [1 2 3; 4 5 6;7 8 9];
B = [ 11 12 13;14 15 16;17 18 19];
Matrix = zeros(size(A,1)+size(B,1), size(A,2));
Matrix(1:2:end, :) = A;
Matrix(2:2:end, :) = B;
Read about indexing in MATLAB: https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!