I would like to get the average of some data only if the sample size is larger than two.
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I would like to get the average of some data only if the size of the sample is larger than two. So, if the sample size is smaller or equal to two, then it will not average. Thanks in advance.
채택된 답변
추가 답변 (1개)
Image Analyst
2017년 2월 2일
Don't worry about it. The average of one value is the same as the value. This code works for any array of any size:
theAverage = mean(yourArray(:))
It's not really worth the extra lines of code to have it do it only in the case of 2 or more elements. Why bother? Really.
댓글 수: 1
참고 항목
카테고리
Help Center 및 File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!