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

1 Kommentar

Image Analyst
Image Analyst am 28 Nov. 2011
Fast comment - what number should be in the blank areas?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 28 Nov. 2011

0 Stimmen

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 Kommentar

Walter Roberson
Walter Roberson am 28 Nov. 2011
There are faster ways using ordinary assignments.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Sparse Matrices finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by