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

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 日

0 投票

D = A;
D(:,1) = B;
or
D = [B A(:, 2:end)];

1 件のコメント

Ryan
Ryan 2015 年 1 月 28 日
Thank you for the quick response!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2015 年 1 月 28 日

コメント済み:

2015 年 1 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by