how to plot time stamps
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a problem while ploting time stamps I am uploading a notpad file with data file and also sharing my code. In data you can see that hours, minutes and seconds with milliseconds are mentioned I don't know any appropriate way to plot it so actually some how I combine hour, minutes and second in one coulmn for every time stamps and then I plot them. normally the values is like this 1.811262700000000e+05 which is actually (18:11:26.27) but few values are like this 1.813172200000000e+04 which is actually (18:13:01.722) so for that values I want to make them 1.8130172200000000e+05. or If any one knows better way to plot time stamps pleases guide me
0 commentaires
Réponse acceptée
dpb
le 2 Mar 2019
Revamp your input parsing a little...
fmt=['%s %d %d %d %f %*s']; % string type, ID, HR, MN, S.SSS, blank record
fid=fopen('rec_0.txt','r'); % open the file
c=textscan(fid,fmt,'delimiter','\n'); % read the file
t=table(datetime(2019,1,1,c{3},c{4},c{5}),categorical(c{1}),categorical(c{2}), ...
'VariableNames',{'Time','Action','Code'}); % convert to table for convenience...
See what we gots...
>> disp(t)
Time Action Code
____________________ _______________ ____
01-Jan-2019 18:11:05 RECORDING_START 1
01-Jan-2019 18:11:26 LEVER_PRESS 3
01-Jan-2019 18:11:26 REWARD 4
01-Jan-2019 18:11:45 LEVER_PRESS 3
01-Jan-2019 18:11:45 REWARD 4
01-Jan-2019 18:12:02 LEVER_PRESS 3
01-Jan-2019 18:12:02 REWARD 4
01-Jan-2019 18:12:22 LEVER_PRESS 3
01-Jan-2019 18:12:22 REWARD 4
01-Jan-2019 18:12:43 LEVER_PRESS 3
01-Jan-2019 18:12:43 REWARD 4
01-Jan-2019 18:13:01 LEVER_PRESS 3
01-Jan-2019 18:13:01 REWARD 4
01-Jan-2019 18:13:22 LEVER_PRESS 3
01-Jan-2019 18:13:22 REWARD 4
01-Jan-2019 18:13:41 LEVER_PRESS 3
01-Jan-2019 18:13:41 REWARD 4
01-Jan-2019 18:13:59 LEVER_PRESS 3
01-Jan-2019 18:13:59 REWARD 4
01-Jan-2019 18:14:25 LEVER_PRESS 3
01-Jan-2019 18:14:25 REWARD 4
01-Jan-2019 18:14:43 LEVER_PRESS 3
01-Jan-2019 18:14:43 REWARD 4
01-Jan-2019 18:15:01 LEVER_PRESS 3
01-Jan-2019 18:15:01 REWARD 4
01-Jan-2019 18:15:18 LEVER_PRESS 3
01-Jan-2019 18:15:18 REWARD 4
01-Jan-2019 18:15:36 LEVER_PRESS 3
01-Jan-2019 18:15:36 REWARD 4
01-Jan-2019 18:15:54 LEVER_PRESS 3
01-Jan-2019 18:15:54 REWARD 4
01-Jan-2019 18:16:11 RECORDING_END 2
>>
The abvoe hardcodes the beginning date as ther first of current year, fix that to whatever is your acquisition date for general use.
Now you can use the plot routines that are datetime aware directly.
Of course, subtract (diff() to get durations.
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!