Fast question!

9 vues (au cours des 30 derniers jours)
Feruz
Feruz le 28 Nov 2011
Hi all,
How do I make this matrix in Matlab?
Thanks
  1 commentaire
Image Analyst
Image Analyst le 28 Nov 2011
Fast comment - what number should be in the blank areas?

Connectez-vous pour commenter.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Sparse Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by