Fast question!

Hi all,
How do I make this matrix in Matlab?
Thanks

1 个评论

Fast comment - what number should be in the blank areas?

请先登录,再进行评论。

 采纳的回答

If the output matrix is to be n by n, then
M = diag(ones(m-1,1),1) + diag(-ones(m-1,1),-1) + diag(1,1-n) + diag(1,n-1);

1 个评论

There are faster ways using ordinary assignments.

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Sparse Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by