How can I get the wall-clock time during my simulation, once an entity reaches a certain block?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm trying to get the real-time spent from when an entity leaves one block, and until it reaches another. I've tried using functions like tic and toc to create a stopwatch, but nothing is working.
For each entity that leaves the entity generator, I'd like it to have its own start time, and then each entity would have its own stop time when it reaches its destination block. So I want an array of start and stop times for each entity, all in wall-clock time.
Any help would be much appreciated.
0 comentarios
Respuestas (1)
Joshua
el 8 de Jul. de 2017
Is this what you are looking for? It gives you the current time in seconds from the start of the day. You could modify it to suit the format you want, but using the clock function is key.
n=30;
times=zeros(n,2);
x=linspace(1,10,10000);
y=cos(x.^2);
format long
for i=1:n
c=clock;
times(i,1)=c(4)*3600+c(5)*60+c(6);
close all
plot(x,y)
c=clock;
times(i,2)=c(4)*3600+c(5)*60+c(6);
end
Note that I made a random loop plot something just to emulate a process taking up time.
Ver también
Categorías
Más información sobre Discrete-Event Simulation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!