summation

8 次查看(过去 30 天)
amar kshirsagar
amar kshirsagar 2011-9-28
how to implement summation in matlab Is there any function for 2D summation in matlab

回答(2 个)

TAB
TAB 2011-9-28
A=rand(5);
As=sum(sum(A));
  3 个评论
Andrei Bobrov
Andrei Bobrov 2011-9-28
Hi Jan!
A= rand(5000);
tic,sum(sum(A));toc
tic,sum(A(:));toc
clear A
Elapsed time is 0.037663 seconds.
Elapsed time is 0.037902 seconds.
MATLAB R2010a, Intel Core2 Duo, 2.13 GHz, 2 GB RAM
TAB
TAB 2011-9-28
On Matlab R2007a , C2D, 4GB RAM
A= rand(5000);
tic,sum(sum(A));toc --> 0.047444 Sec
tic,sum(A(:));toc --> 0.047441 Sec
Yes, Andrei's version is faster. :-)

请先登录,再进行评论。


Andrei Bobrov
Andrei Bobrov 2011-9-28
sum(A(:)) % A - double array 2d

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by