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

1 件のコメント

Image Analyst
Image Analyst 2011 年 11 月 28 日
Fast comment - what number should be in the blank areas?

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

 採用された回答

Walter Roberson
Walter Roberson 2011 年 11 月 28 日

0 投票

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 件のコメント

Walter Roberson
Walter Roberson 2011 年 11 月 28 日
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