Extrapolate the times of entry and exit in timetable
Mostra commenti meno recenti
I have a timetable: I want to extrapolate the times of entry and exit from a certain room. I did a for loop on rows and two if loops: the first, I take the column for all the rooms on the i-th row (pir_tab_night.Column1streamId (i)) and I place it == at the room I'm interested in; I also added the condition that the start time must be 0 (in such a way as to take the first line in which the person enters the room) ... here it gives me error (Comparison is not defined between datetime and double arrays). the second if cycle is for the time out of the room: within this cycle I calculate the vect_duration for each (t_end-t_start) and then I go to concatenate with the function cat(1, vect_duration, t_end-t_start). Finally I repositioned the times = 0 to start a new count. This is my code:
vect_duration = []; t_start = 0; t_end = 0; for i = 1:length(pir_tab_night.t) if pir_tab_night.Column1streamId(i) == 'dbuid-17' & t_start == 0 t_start = pir_tab_night.t(i); end if pir_tab_night.Column1streamId(i) ~= 'dbuid-17' & t_start ~= 0 t_end = pir_tab_night.t(i-1); vect_duration = t_end - t_start; vect_duration = cat(1, vect_duration, t_end-t_start); t_start = 0; t_end = 0; end end
Can someone help me? Thank you
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Startup and Shutdown in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!