How can I create a matlab matrix below?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
kimjandi
el 3 de Mzo. de 2021
Respondida: Walter Roberson
el 3 de Mzo. de 2021
Hi, I've been wanting to construct a matlab matrix that is n by n. and looks like this. I've beeen trying to use diag but the function diag doesn't provide this. so m a bit confused. Please help!
0 comentarios
Respuesta aceptada
Walter Roberson
el 3 de Mzo. de 2021
N = 6;
diag(-2*ones(1,N)) + diag(ones(1,N-1),-1) + diag(ones(1,N-1),1)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!