finding the a average of matrix any better way

 채택된 답변

Walter Roberson
Walter Roberson 2012년 5월 16일

2 개 추천

mean(a(:))

댓글 수: 2

Sharon
Sharon 2012년 5월 16일
thanks Walter..
Jan
Jan 2012년 5월 16일
For some Matlab versions, sum(sum(a))/numel(a) is measurable faster than mean(a(:)) for two reasons: In pre-2011 (don't know exactly the release number) versions of Matlab, sum(A) was vectorized, when A has multiple dimensions, while a vector was processed in one thread only. For very small vectors the overhead of calling the M-file mean mattered.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Thomas
Thomas 2012년 5월 16일

1 개 추천

Don't know if this is better..
a=[2 4 5;3 2 1;2 3 8;4 1 9];
average=mean(mean(a))

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

태그

Community Treasure Hunt

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

Start Hunting!

Translated by