Fast question!

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

0 votos

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 Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 28 de Nov. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by