Filter löschen
Filter löschen

how to calculat average value for array?

2 Ansichten (letzte 30 Tage)
janny
janny am 9 Nov. 2014
Kommentiert: janny am 9 Nov. 2014
i have array (one column) as [12,17,25,30,6] i want to calculate the average value between minimum number and maximum number within the array, and the result should be positive number as if the average is 15.23 it should exclude the decimal fraction 0.23 and give the result as 15.

Akzeptierte Antwort

Guillaume
Guillaume am 9 Nov. 2014
mean to calculate average.
round, fix, ceil or floor to round your number depending on the rounding mode you want.
min and max to find the minimum and maximum
Is this what you want:
v = [12 17 25 30 6]';
round(mean([min(v) max(v)]))

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices 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!

Translated by