How can i describe this matrix of the size M by M by using ''spdiags command'' ?
1 次查看(过去 30 天)
显示 更早的评论
2 个评论
John D'Errico
2023-10-9
What have you tried? If nothing, why not?
You clearly know what function you need to use. The diagonals are trivial to generate, since there are only two of them, and the matrix is constant down those diagonals. So why not take a shot, and then show what you tried?
回答(1 个)
Walter Roberson
2023-10-10
Hint:
init = repmat((1:6).',1,2)+[0 10]
full(spdiags(init, [-4 4], spalloc(6,6,0)))
So negative diagonals take elements from the top of the initialization matrix, and positive diagonals take elements from the bottom of the initialization matrix.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!