Extract arrays of a matrix using FOR loop
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone
the question is: Write a code using FOR loop that extract Main diagonal of any n*n matrix.
i know diag will do the job but i wanna write it with FOR loop
Thanks in advance
0 comentarios
Respuestas (1)
AKAYDIN
el 19 de En. de 2023
A = rand(10,10) % random matrix when n=10
for i=1:length(A)
diagonal(i) = A(i,i);
end
diagonal
0 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!