which one is the correct procedure for summation

1 visualización (últimos 30 días)
Renjith V Ravi
Renjith V Ravi el 13 de Feb. de 2017
Respondida: Walter Roberson el 13 de Feb. de 2017
I want to implement the following equation
Kindly tell me,which method is correct
ID =0;
for i=1:256
ID = ID+HD(i);
end
or otherwise
ID = sum(HD(1:256))
Please help me

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Feb. de 2017
ID = sum(HD(1:256)) is faster.
If you were summing large enough arrays then there could be difference in the output due to round off differences when the large summation was handed over to fast routines that use multiple threads to create partial sums that are then added together.

Más respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by