user2013590
user2013590

Reputation: 17

Calculate an average every 15 seconds

I have a time row with a matrix of 1 x 14401 first I put in the command:

data.time2(1,2) - data.time2(1,1)

which produced 2.8935e-06 which is the time step between each point (I was told this is in days). First I need to convert this into seconds but I am not sure of the commands and then average every 15 seconds.

Upvotes: 1

Views: 534

Answers (1)

plesiv
plesiv

Reputation: 7028

% convert to seconds
seconds = data.time2 * 24 * 60 * 60;

Since step between points is 0.25 seconds, you should average 60 points in a row.

% mask for averaging every 60 points
W = 60;
mask = ones(1,W) / W;

% calculating averages, length will be: 14401 - 60 + 1 = 14342
averages = conv( seconds, mask, 'valid' );

Upvotes: 2

Related Questions