I need to write a function to calculate the maximum row sum of a matrix A using a for loop
Mostrar comentarios más antiguos
I need to write a function to calculate the maximum row sum of a matrix A. It needs to give outputs of the maximum row sum of A and the row on which that maximum occurs. I am only allowed to use loops in my function and no built-in functions like sum etc. Anyone got any ideas or know how to write this into Matlab... thanks:)
1 comentario
Jos (10584)
el 5 de Dic. de 2017
As this is obviously homework (" I am only allowed to ...") we have to ask you:
What did you try yourself so far?
Respuestas (1)
Jos (10584)
el 4 de Dic. de 2017
To get you started
current_max = -Inf ;
current_max_rowindex = 0;
for row_index = 1:size(A,1)
row_sum = A(row_index,1) ;
for col_index = 2:...
row_sum = row_sum + ...
end
if row_sum > ...
...
end
end
Categorías
Más información sobre Loops and Conditional Statements 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!