which one is the correct procedure for summation
1 次查看(过去 30 天)
显示 更早的评论
I want to implement the following equation
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/160677/image.png)
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 个评论
采纳的回答
Walter Roberson
2017-2-13
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!