write a script that creates identity matrices of any size without using the function eye
Mostrar comentarios más antiguos
thank you
2 comentarios
@ Chloe St John: it is not appreciated when you delete your question text. This has the effect of treating us as your own disposable personal assistants, which we are not. If you want private help then you will find plenty of consultants who will gladly take your money and offer whatever private advice you want.
If you are concerned about your tutor or professor finding that you have been given all answers to your homework, then perhaps consider that before posting onto a public forum:
Rena Berman
el 5 de Mzo. de 2019
(Answers Dev) Restored edit.
Respuestas (2)
Don't use a loop, learn to write simple vectorized code:
N = 5;
M = zeros(N);
M(1:N+1:end) = 1
1 comentario
Eduardo Lugo Hernández
el 21 de Mzo. de 2023
:)
Kevin Phung
el 24 de En. de 2019
n = zeros(5); %square matrix
for i= 1:size(n,1)
n(i,i) = 1;
end
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!