mean vaue every one minute

1 view (last 30 days)
Thar
Thar on 20 Sep 2016
Commented: Thar on 20 Sep 2016
Hi all!
I have a matrix with two columns, time and temperature. I want to find mean value of temperature for every 1 minute. Because my time is on hours every 0.0166. my matrix is:
12.3539 25.8
12.3537 24.9
12.3590 25.1
12.3624 25.3
12.3692 24.5
12.3726 26.2
12.3777 26.1
12.3811 26.8
12.3861 27.4
I want to find mean value from 1-5 and the from 6-9 and so on, until 2897.
Are there any ideas?
Thank you!

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 20 Sep 2016
data = [12.3539 25.8
12.3537 24.9
12.3590 25.1
12.3624 25.3
12.3692 24.5
12.3726 26.2
12.3777 26.1
12.3811 26.8
12.3861 27.4];
t = 1/60;
th = [0;cumsum(diff(data(:,1)))];
ii = floor(abs(th)/t)+1;
T = accumarray(ii,data(:,2),[],@mean);
  3 Comments
Andrei Bobrov
Andrei Bobrov on 20 Sep 2016
Edited: Andrei Bobrov on 20 Sep 2016
Hi Thodoris! Please give small part your data (use 'attach').
Thar
Thar on 20 Sep 2016
12,353855 23.1
12,355585 24.5
12,357284 22.9
12,358982 23.8
12,360677 25.2
12,362379 22.5
12,364070 23.8
12,365759 24.2
12,367457 26.2
12,369162 25.9
12,370863 24.6
12,372571 26.7
12,374269 21.9
12,375964 24.8
12,377664 25.3
12,379358 22.7
12,381062 21.5
12,382759 25.9
12,384461 24.3
12,386174 27.9
12,387877 22.8
12,389589 27.9
12,391289 28.1
12,392999 28.5
12,394866 28.4
12,396653 25.4
12,398355 24.6
12,400059 27.9
12,401765 25.9
12,403478 24.9
12,405176 24.6
12,406878 25.1
12,408587 26.9
12,410285 27.2
12,411974 28.4
12,413673 28.1
12,415377 28.5
12,417084 28.3
12,418792 27.9
12,420502 27.5
12,422201 23.5
12,423905 25.7
12,425616 26.9
12,427327 28.4
12,429039 21.6
12,430742 24.8
12,548259 27.2
12,549967 29.1
12,551696 28.5
12,553411 26.2
12,555119 25.3
12,556835 25.6
12,558541 24.9
12,560253 24.7
12,561979 25.8
12,563707 25.1
12,565423 25.2
12,567127 26.9
12,568838 26.3
12,570549 26.9
12,572253 25.9
12,573960 24.3
12,575676 22.9
12,577389 23.6
12,579099 21.9
12,580812 26.9
12,582526 25.3
12,584236 26.7
12,585938 28.1
12,587654 27.8
12,589361 26.9
12,591072 25.9
12,592776 23.2
12,594488 26.8
12,596212 27.2
12,597924 29.8
12,599636 30.5
12,601343 33.8
12,603080 32.7
12,604791 31.9
12,606495 30.8
12,608208 29.7
12,609928 29.5
12,611652 28.8
12,613373 28.7
12,615088 28.5
12,616798 27.5
12,618511 25.9
12,620223 26.2
12,621948 25.9
12,623668 27.5
12,625381 28.3
12,627093 27.1
12,628804 26.2
12,746722 26.8
12,748493 27.9
12,750228 22.1
12,751951 27.9
12,753672 25.9
12,755397 24.6
12,757117 23.9
12,758842 22.8
12,760568 23.4
12,762300 24.1
12,764025 23.9
12,765754 23.6
12,767480 24.5
12,769198 24.7
12,770914 25.8
12,772649 26.7
12,774382 26.8
12,776115 25.2
12,777848 24.8
12,779577 25.2
12,781286 25.8
12,783013 26.1
12,784730 24.5
12,786441 25.7
I want mean values from 1:10, 11:20, 21:30, 31:40, 41:46, 47:56, 57:66, 67:76 and so on. The script has wrong after the 46 value.

Sign in to comment.

More Answers (1)

Steven Lord
Steven Lord on 20 Sep 2016
If you're using release R2016b, consider storing your data in a timetable and using retime on that timetable using a time step of 'minutely' and a method of 'mean'.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!