필터 지우기
필터 지우기

Averages using intervals in a vector

조회 수: 3 (최근 30일)
Orlando Ramirez-Valle
Orlando Ramirez-Valle 2021년 3월 28일
댓글: Star Strider 2021년 3월 28일
Hello,
How can I get an average of a vector using intervals?
Example:
(2500 values) vector
I want to add the following intervals in 1D:
Intervals; (3,3,3,3,3,3,3,3,3 . . .3)
Example:
Data
57.303
55.135
47.572
38.165
43.554
34.521
33.017
31.675
29.651
Result (average)
53.33
38.74
31.44
Is it possible to do it in a loop?
Thanks in advance

채택된 답변

Star Strider
Star Strider 2021년 3월 28일
I have not certain idea what you are asking.
One option is to use the movmean function.
Another option:
v = rand(2500,1); % Create Vector To Test Code
vr = reshape(v(1:numel(v)-rem(numel(v),3)),3,[]); % Reshape Vector To (3x833)
vrm = mean(vr); % Column Mean
.
  댓글 수: 2
Orlando Ramirez-Valle
Orlando Ramirez-Valle 2021년 3월 28일
great it worked thanks
Star Strider
Star Strider 2021년 3월 28일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by