How to plot average day from monthly data

Hi!
I have monthly data containing vehicle's flow (vehicles/min) during one month. How can I get one plot showing the average vehicles per minute during the day. In other words, I need to plot the average flow (veh/min) every minute in an average day.
my data looks something like this
Flow - timestamp
23veh - 01/01/14 00:00
24veh - 01/01/14 00:01
17veh - 01/01/14 00:02
32veh - 01/01/14 00:03
...
14veh - 01/01/14 23:59
19veh - 02/01/14 00:00
25veh - 02/01/14 00:01
...
24veh - 31/01/14 23:59
Thank you in advance for your help

3 Comments

Are your data ‘something like’ what you posted or exactly like what you posted? Is the string ‘veh’ part of the data?
Hi
The data is similar but not exactly, the flow data is a vector (double) and the date-stamp is a string.
Thanks
See below...it's no problem, it's an ASCII file. I pasted a few lines of your posted file and tested the read, even.

Sign in to comment.

Answers (2)

[v,d,m,y,h,mn]=textread('abe.dat','%dveh - %2d/%2d/%2d %2d:%2d','headerlines',1);
vbar=mean(reshape(v,24*60,[]));
plot(vbar)
Ain't Matlab easy (and fun) ??? :)
fid=fopen('file.txt')
data=textscan(fid,'%s %s %s %s')
fclose(fid)
flow=cellfun(@(x) str2double(regexp(x,'[0-9]+(\.)?([0-9]+)?','match')),data{1},'un',0)
date1=cellfun(@(x,y) [x ' ' y],data{3},data{4},'un',0)
date2=datevec(date1,'dd/mm/yy HH:MM')
a=date2(:,1:3)
[ii,jj,kk]=unique(a,'rows')
b=accumarray(kk,cell2mat(flow),[],@mean)
f=cellstr(datestr([ii zeros(size(ii,1),3)],'dd/mm/yyyy'))
out=[f num2cell(b) ]

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Asked:

on 10 Apr 2014

Answered:

on 12 Apr 2014

Community Treasure Hunt

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

Start Hunting!