I have a text data file, which includes timestamp like 20150727084239.533 which represent 2015-07-27 08:42:39.533. And I have two questions when dealing with these. 1. how can I use textscan and have it recognized as time? I have the current code shown below, and it only load into the data array as numbers.
Load Vehicle A_0727_L2 Timestamp
filename='Vehicle A_0727_1200.txt';fid=fopen(filename,'r');for k=1:2; tline=fgetl(fid); endtimestamp1200=zeros(1,7931);t=1;while tline~=-1 datestr=regexp(tline,'(?<=STime="20150727).*(?=" ETime)','match'); tempdata2=textscan(datestr{1},'%f'); timestamp1200(:,t)=tempdata2{1}; t=t+1; tline = fgetl(fid);endfclose all;
When I use %{HH:mm:ss.FFF}D to replace %f, system returns the following errors:
Error using textscanUnable to read the DATETIME data with the format 'HH:mm:ss.FFF'. If thedata is not a time, use %q to get string data.
Error in C_July27_L2_Data (line 39) tempdata2=textscan(datestr{1},'%{HH:mm:ss.FFF}D');
2. How do I use the load time to perform subtraction like 463 seconds from the loaded data, etc.
thanks!
Best Answer