Fast question!

10 visualizaciones (últimos 30 días)
Feruz
Feruz el 28 de Nov. de 2011
Hi all,
How do I make this matrix in Matlab?
Thanks
  1 comentario
Image Analyst
Image Analyst el 28 de Nov. de 2011
Fast comment - what number should be in the blank areas?

Iniciar sesión para comentar.

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Sparse Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by