필터 지우기
필터 지우기

Filtering Data

조회 수: 3 (최근 30일)
ndb
ndb 2011년 4월 27일
Hello,
I am trying to compute an average and variance of a large data set (~330000 rows x 3 different columns), but I'd like to take the average and var. of every 240 entries. I think you'd call this a moving average/variance, but I'm not sure.
Can you please provide hints as to accomplish this? I'm thinking either a for-loop or using the 'filter' function, but am not sure how to approach this problem...
Thanks in advance,
Nic
  댓글 수: 2
ndb
ndb 2011년 4월 27일
Also,
I already have a column that records the minute each measurement is made, there being 4 measurements taken each second (4 * 60 = 240 measurements a minute). So I'm thinking that I might be able to construct a loop that looks to see if the minute column has changed (say, from minute 0 to minute 1) and if so, average/take variance of the values stored in some temporary variable...
Am I on the right track?
Andrew Newell
Andrew Newell 2011년 4월 27일
By "entries" do you mean rows or total number of variables?

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

채택된 답변

Jarrod Rivituso
Jarrod Rivituso 2011년 4월 27일
Here's a filter function example for ya...
Example code for simple moving average:
data = rand(4000,3);
window = ones(240,1)/240;
filtered_data = filter(window,1,data);
Hope this helps!
  댓글 수: 1
Jarrod Rivituso
Jarrod Rivituso 2011년 4월 27일
After reading your additional comment, here's a fancy bit of code that you might find useful:
%create random data
data = rand(100,4);
%emulate 4th column a bit
data(1:10,4) = 1;
data(11:20,4) = 2;
%extract all rows where 4th column is equal to 1
extractedData = data(data(:,4) == 1,:)
%find variance of extracted data
var(extractedData)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Statistics and Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by