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

12 Ansichten (letzte 30 Tage)
Ryan
Ryan am 28 Jan. 2015
Kommentiert: Ryan am 28 Jan. 2015
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.

Akzeptierte Antwort

David Young
David Young am 28 Jan. 2015
D = A;
D(:,1) = B;
or
D = [B A(:, 2:end)];

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by