How do I insert a column with zeros in the second column of a mxn matrix?

5 ビュー (過去 30 日間)
SAI KRISHNA CHADA
SAI KRISHNA CHADA 2017 年 11 月 10 日
コメント済み: SAI KRISHNA CHADA 2017 年 11 月 10 日
Hello, I would like to insert a column with zeros in the second column of a (mxn) matrix, after which the matrix would be a mx(n+1) matrix. It would be really grateful, if someone could help me on this. Thank you.

採用された回答

Mischa Kim
Mischa Kim 2017 年 11 月 10 日
編集済み: Mischa Kim 2017 年 11 月 10 日
Brute force:
A = [1 2 3; 4 5 6; 7 8 9]
A = [zeros(size(A,1),1) A];
A(:,[1 2]) = A(:,[2 1])
  1 件のコメント
SAI KRISHNA CHADA
SAI KRISHNA CHADA 2017 年 11 月 10 日
Thanks a lot for your promt solution. It works! :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by