Fast question!

9 Ansichten (letzte 30 Tage)
Feruz
Feruz am 28 Nov. 2011
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
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 Help 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