I would like to get the average of some data only if the sample size is larger than two.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Md
am 2 Feb. 2017
Kommentiert: Walter Roberson
am 28 Dez. 2017
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.
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 2 Feb. 2017
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 Kommentar
Siehe auch
Kategorien
Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!