Mostrar comentarios más antiguos
how to implement summation in matlab Is there any function for 2D summation in matlab
Respuestas (2)
TAB
el 28 de Sept. de 2011
A=rand(5);
As=sum(sum(A));
3 comentarios
Jan
el 28 de Sept. de 2011
SUM(SUM(A)) is slower than SUM(A(:) on older Matlab versions (I assume <= 2009a), and on single core machines. On a modern system SUM(SUM(A)) is parallelized and faster in consequence.
Andrei Bobrov
el 28 de Sept. de 2011
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
el 28 de Sept. de 2011
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
el 28 de Sept. de 2011
sum(A(:)) % A - double array 2d
Categorías
Más información sobre Language Fundamentals en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!