How to insert a smaller diagonal into a Matrix?
2 次查看(过去 30 天)
显示 更早的评论
I'm struggling to generate a matrix M=[0 0 1 0 0; 0 0 0 1 0; 0 0 0 0 1; 0 0 0 0 0; 0 0 0 0 0], quickly without entering each entry by hand. I gather there is a quicker way.
I know I can create the 5x5 identity matrix using M=eye(5) but am unsure how to move the diagonal of 1s across 2. Any help would be appreciated
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!