Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Reading a CR1000 data file into MATLAB


jfo Feb 19, 2009 10:39 PM

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.


IslandMan Feb 21, 2009 11:50 AM

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


kennaster Jul 2, 2009 02:12 AM

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.


Dana Jul 7, 2009 07:58 PM

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


RiverOfNoReturn Jul 7, 2009 10:40 PM

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');


jfo Jul 12, 2009 09:07 PM

Many thanks for your responses!


sjp Mar 11, 2010 11:26 PM

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.


cafeilde Mar 12, 2010 03:31 AM

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);

Log in or register to post/reply in the forum.