MATLAB Answers

0

which one is the correct procedure for summation

Asked by Renjith V Ravi on 13 Feb 2017
Latest activity Answered by Walter Roberson
on 13 Feb 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

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Walter Roberson
on 13 Feb 2017
 Accepted Answer

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.

  0 Comments

Sign in to comment.