How to take a mean from a range of values
조회 수: 6 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
채택된 답변
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))
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!