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

1 回表示 (過去 30 日間)
Bob
Bob 2019 年 5 月 19 日
コメント済み: darova 2019 年 5 月 19 日
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.

採用された回答

darova
darova 2019 年 5 月 19 日
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 件のコメント
Bob
Bob 2019 年 5 月 19 日
Hi,
Error appears with following massage:
Index exceeds the number of array elements (21422).
darova
darova 2019 年 5 月 19 日
My bad, try:
for i = 1:m:n-m+1

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by