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

Star Strider
Star Strider 2014년 4월 10일
Are your data ‘something like’ what you posted or exactly like what you posted? Is the string ‘veh’ part of the data?
Abraham
Abraham 2014년 4월 10일
Hi
The data is similar but not exactly, the flow data is a vector (double) and the date-stamp is a string.
Thanks
dpb
dpb 2014년 4월 10일
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.

댓글을 달려면 로그인하십시오.

답변 (2개)

dpb
dpb 2014년 4월 10일

1 개 추천

[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
Azzi Abdelmalek 2014년 4월 12일

0 개 추천

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) ]

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2014년 4월 10일

답변:

2014년 4월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by