How to take a mean from a range of values

7 ビュー (過去 30 日間)
Sophie
Sophie 2023 年 5 月 4 日
コメント済み: Sophie 2023 年 5 月 4 日
Hi, I have variables that look something like this (simplified):
x = [1 2 3 4 5]
y = [10 20 30 40 50]
I then plotted x and y. Now, I want to take the mean value of y from x = 2.5-4.5.
I'm not sure how to take a mean of a range of values.
Thanks!

採用された回答

the cyclist
the cyclist 2023 年 5 月 4 日
x = [1 2 3 4 5];
y = [10 20 30 40 50];
xInRange = (x>2.5) & (x<=4.5);
mean(y(xInRange))
ans = 35
  1 件のコメント
Sophie
Sophie 2023 年 5 月 4 日
thank you! so simple

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by