필터 지우기
필터 지우기

Performing a repeated calculation within a vector

조회 수: 1 (최근 30일)
Dirk
Dirk 2015년 12월 7일
답변: Walter Roberson 2015년 12월 7일
Hi Everyone, I have a column of data, say with 40,000 data points. I want to reduce this to 4,000 by creating a new variable which is the mean of every 10 data points. So the new variable would have the mean of the first 10 data points, followed by the mean of the second 10 data points, and so on until there are 4,000 data points.Thanks.

채택된 답변

Walter Roberson
Walter Roberson 2015년 12월 7일
Provided that the vector length is an exact multiple of the group size,
mean( reshape(TheVector, GroupSize, []) )
If there would be an incomplete group then you need to either pad the vector or else handle it differently. If you have a fairly new MATLAB then you can pad with NaN and use the 'omitnan' flag to mean(); see http://www.mathworks.com/help/matlab/ref/mean.html

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by