필터 지우기
필터 지우기

finding the a average of matrix any better way

조회 수: 1 (최근 30일)
Sharon
Sharon 2012년 5월 16일
a=[2 4 5;3 2 1;2 3 8;4 1 9];
average=sum(sum(a))/numel(a)
Any better way to do this..

채택된 답변

Walter Roberson
Walter Roberson 2012년 5월 16일
  댓글 수: 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일
Don't know if this is better..
a=[2 4 5;3 2 1;2 3 8;4 1 9];
average=mean(mean(a))

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by