How can I create a simple matrix of 4 by 4 using a "for" loop. to make a diagnol of 1's starting from top right to bottom left?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Not sure where to start this is my second time using MATLAB, thanks!
1 comentario
Respuestas (3)
Michael Joslin
el 24 de En. de 2013
Editada: Michael Joslin
el 24 de En. de 2013
Heres a way to do it without a for loop if your interested:
a = ones(4); a = diag(diag(a)); rot90(a)
This might not be too helpful if all of your other elements are not zero.
0 comentarios
Sean de Wolski
el 24 de En. de 2013
Editada: Sean de Wolski
el 24 de En. de 2013
I = fliplr(eye(4));
2 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements 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!