Transform a matrix in a special way
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Baptiste Charrier
el 10 de Feb. de 2021
Respondida: Fangjun Jiang
el 10 de Feb. de 2021
Hi !
I have this kind of matrix :
A=[1 2 3 4 5 6 7 8 9 10]
And I would like to transform it in this way:
B=[0 1 2 3 4 ; 0 0 5 6 7 ; 0 0 0 8 9 ; 0 0 0 0 10 ; 0 0 0 0 0]
I am looking for a simple method to do it, may you help me please ?
0 comentarios
Respuesta aceptada
Walter Roberson
el 10 de Feb. de 2021
Editada: Walter Roberson
el 10 de Feb. de 2021
fiddle with
B = zeros(5)
B(tril(B,-1)==1) = A;
I posted exact code about two weeks ago. Needs a couple of flips.
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!