Borrar filtros
Borrar filtros

Create a matrix with non zero entries on the diagonal and subdiagonal and zero elsewhere

2 visualizaciones (últimos 30 días)
I am confused on how to generate a 4 by 4 matrix which has ones on the diagonal and zeroes on the lower subdiagonal right beneath the diagonal and 2s on the subdiagonal right above the diagonal. In addition, there should be 0 entries elsewhere.

Respuestas (1)

David Hill
David Hill el 4 de Mzo. de 2021
eye(4)+diag([2 2 2],1);

Categorías

Más información sobre Operating on Diagonal 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