exec & fetch commands (Problem with data format?)

2 次查看(过去 30 天)
Hi, I'm having some problems importing a time variable from my database into MATLAB. I think the problem might have something to do with the format of the time parameter which is:
HH:MM:SS.MS
Example:
00:04:13.46
H = Hour, M = Minute, S = Second, MS = Millisecond.
When I use dexplore or querybuilder MATLAB doesn't seem to process the fact there is a time field here, instead just returning a [ ]. I think this may be something to do with the format of the time field.
My current code looks like this:
%Set preferences with setdbprefs.
setdbprefs('DataReturnFormat', 'structure');
setdbprefs('NullNumberRead', 'NaN');
setdbprefs('NullStringRead', 'null');
%Make connection to database. Note that the password has been omitted.
%Using ODBC driver.
conn = database('DATABASE', '', '');
%Read data from database.
curs = exec(conn, ['SELECT ARDAT.Date'...
' , ARDAT.Time'...
' FROM DATABASE.dbo.ARDAT ']);
curs = fetch(curs);
close(curs);
%Assign data to output variable
data = curs.Data;
%Close database connection.
close(conn);
%Clear variables
clear curs conn
Is there a particular way I can force MATLAB to read the Time field as a string instead? Then I can just post process the data to fix it.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by