Guest User

Untitled

a guest
Jan 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. inTime = cumsum(rand(100,1)); %They show up randomly
  2. outTime = inTime + rand(100,1) + 0.25; % Stay for 0.25 to 1.25 hrs
  3.  
  4. inCount = ones(size(inTime)); %Add one for each entry
  5. outCount = ones(size(outTime))*-1; %Subtract one for each exit.
  6.  
  7. allTime = [inTime; outTime]; %Stick them together.
  8. allCount = [inCount; outCount];
  9.  
  10. [allTime, idx] = sort(allTime);%Sort the timestamps
  11. allCount = allCount(idx); %Sort counts by the timestamps
  12. allCount = cumsum(allCount); %total at any given time.
  13.  
  14. plot(allTime,allCount);%total at any given time.
Add Comment
Please, Sign In to add comment