How do I insert a column with zeros in the second column of a mxn matrix?
7 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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])
更多回答(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!