write a binary file from SQL-Server2005 and read it in Matlab

1 次查看(过去 30 天)
I can write binary data from Matlab and read it very easily. However, I'm facing problems while writing binary data from SQL Server 2005 (x64 machine, WinServer2003) and reading it in Matlab.
create table #temp (C1 int, C2 float,C3 float)
insert into #temp (C1,C2,C3) SELECT 1,2,3
insert into #temp (C1,C2,C3) SELECT 4,5,6
select convert(binary,C1),convert(binary,C2),convert(binary,C3)
from #temp
drop table #temp
-- This is output to a file: 'mydata.bin' with settings 'Save-->ANSI' (other option: Unicode)
I now try to read this data in Matlab:
fid = fopen('mydata.bin', 'r');
[Data, count] = fread(fid, [2,3], '??????=>double',0, 'a');
fclose(fid);
I get some weird output as 824707597, 539587368, ...... Shall appreciate your help! Thanks. I found the following links helpful: http://msdn.microsoft.com/en-us/library/ms187928.aspx, http://msdn.microsoft.com/en-us/library/ms187745.aspx

回答(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