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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Database Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!