Am unable to wrap my head on this question regarding for loop , can someone explain the question and maybe write the code please.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Dawud Adam Rabiu
el 10 de Nov. de 2021
Comentada: Awais Saeed
el 10 de Nov. de 2021
1 comentario
Walter Roberson
el 10 de Nov. de 2021
A number of solutions have been posted already; search for halfsum
Respuesta aceptada
Awais Saeed
el 10 de Nov. de 2021
Why use a loop if it can be done without it
A = [1 2 3; 4 5 6; 7 8 9];
[sum_of_elements] = halfsum(A)
function [sum_of_elements] = halfsum(M)
A = M;
sum_of_elements = sum(triu(A), 'all');
end
4 comentarios
Awais Saeed
el 10 de Nov. de 2021
I have added some comments. For better understanding use debug mode.
Más respuestas (0)
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!