Fast question!

9 visualizzazioni (ultimi 30 giorni)
Feruz
Feruz il 28 Nov 2011
Hi all,
How do I make this matrix in Matlab?
Thanks
  1 Commento
Image Analyst
Image Analyst il 28 Nov 2011
Fast comment - what number should be in the blank areas?

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 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 Commento
Walter Roberson
Walter Roberson il 28 Nov 2011
There are faster ways using ordinary assignments.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Sparse Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by