How to plot average day from monthly data
Ältere Kommentare anzeigen
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 Kommentare
Star Strider
am 10 Apr. 2014
Are your data ‘something like’ what you posted or exactly like what you posted? Is the string ‘veh’ part of the data?
Abraham
am 10 Apr. 2014
dpb
am 10 Apr. 2014
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.
Antworten (2)
dpb
am 10 Apr. 2014
[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) ??? :)
Azzi Abdelmalek
am 12 Apr. 2014
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) ]
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!