I have a bunch of .dat files from a CR1000 logger and I am trying to read them into MATLAB. However, being new to MATLAB I am having trouble getting the program to deal with the dd.mm.yyyy and time format of the CSI .dat files. Any advice on how to code this in and to keep the date and time columns as date and times? Thanks in advance.
I'm not familiar with MatLab but you could use the Split report generation software which is included in Loggernet to create a more suitable time stamp set for the data.
Good Luck,
IslandMan
Matlab is really picky about timestamps. This won't help you with this problem, but in the future, if you output our time as a date array (yyyy,doy,hhmm), ML can easily handle this form. Good luck.
I have had a customer or two send me files that could be used for Matlab, but I am not at liberty to distribute those. I will contact the customers and ask them to look in on the forum :) They may have something they can share.
And as IslandMan mentions, you can use Split to convert the date to any format you need. See the most recent Split help on the Date() function and its format string syntax.
Regards,
Dana
JFO,
Your best bet is to use the "datenum" and "datestr" functions in Matlab. How exactly are your dates formatted? There are a number of pre-defined date string formats in the "datestr" function, but you can also use "Free Form" Date format specifiers. Here's an example for a code that reads level logger data, but it should give you an idea
This loads in the raw csv file as variable C, the date string is in the first cell
C = textscan(fid, '%s %f %f %f %f','delimiter', ',');
And this line converts the string format into the Matlab date number format
MatDate = datenum(C{1,1}, 'mm/dd/yyyy HH:MM:SS PM');
Many thanks for your responses!
As others have mentioned, use Split to customize the date in your datafile.
What I do is use Split to produce a 'serial' date field with the edate instruction in the select panel.
Matlab has no issues at all with the serial date, and then in matlab you can use datetick('x','dd-mm-yyyy') (or whatever formatting) to format your x-axos on your graph as you wish. Works for both date and time without issue.
RiverOfNoReturn‘s method is good.
But if you wanna split the hours and the minutes, you can try the following code.
%read one of the data line from the raw data file without headlines.
data=textscan(fid1,'%s%s%s%s%s%s%s%s%s%s',1,'delimiter',',');
%extract the time data including hours and minutes.
ccc=data{1,1}{1,1};
%extract hours from ccc in the format of string.
hourString=ccc(13:14);
%convert string to number.
hourInt=str2num(hourString);
%extract minutes from ccc in the format of string.
minuteString=ccc(16:17);
%convert string to number.
minuteInt=str2num(minuteString);