I need to write a function to calculate the maximum row sum of a matrix A using a for loop

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

As this is obviously homework (" I am only allowed to ...") we have to ask you:
What did you try yourself so far?

Iniciar sesión para comentar.

Respuestas (1)

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.

Etiquetas

Preguntada:

el 4 de Dic. de 2017

Comentada:

el 5 de Dic. de 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by