How to get mean value minute by minute in a vector.

1 view (last 30 days)
Hi, I have vector of 21422x1and I want to be able to get mean value every 60 second. Is there any way to do this? I also have t2 time variable length 21433.
(sample was taken at 1Hz)
I could get the mean value in excel it self but do not know how I can get the time variable, how to identify the each 60 second ?
Thanks in Advance.

Accepted Answer

darova
darova on 19 May 2019
If the frequency is 1Hz then:
k = 1; % counter of mean value vector
n = length(v); % length of original data vector
m = 60*1; % every 60th values at 1Hz frequency
v1 = zeros( fix(n/m),1 ); % vector with mean values
for i = 1:m:n
v1(k) = mean( v(i:i+m) );
k = k + 1;
end
Any questions?
  2 Comments
Bob
Bob on 19 May 2019
Hi,
Error appears with following massage:
Index exceeds the number of array elements (21422).

Sign in to comment.

More Answers (0)

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!