How to create a matrix by inserting a vector into another matrix?

조회 수: 12 (최근 30일)
Ryan
Ryan 2015년 1월 28일
댓글: Ryan 2015년 1월 28일
Hello,
Let's say I have matrix A, and matrix B. Matrix A is a 5x5, and Matrix B is a 5x1. I would like to take all of matrix B and insert it into the first column of matrix A, replacing those values in matrix A BUT making a completely new matrix, D, leaving A and B unchanged.

채택된 답변

David Young
David Young 2015년 1월 28일
D = A;
D(:,1) = B;
or
D = [B A(:, 2:end)];

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by