필터 지우기
필터 지우기

how to calculat average value for array?

조회 수: 2 (최근 30일)
janny
janny 2014년 11월 9일
댓글: janny 2014년 11월 9일
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.

채택된 답변

Guillaume
Guillaume 2014년 11월 9일
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)]))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by