I'm aware that fread can be used for reading binary data. I read somewhere that it can also read text files. I have a numeric text file that I generated using BCP utility and SQL Server. I am trying to read this huge data in Matlab. textscan and fscanf are slow in my case. fread reads the data and prints out their ASCII values. Is there a way I can read the data correctly using fread? Because text files are big, fread can give me a quicker solution.
BCP "SELECT 3,1 UNION ALL SELECT 9,13" queryout "Trial.txt" -c t"," -S"srvr" -U"login" -P"pwrd"
% In Matlab -->
fid = fopen('Trial.txt','r') ;
fread(fid)
fclose(fid);
ASCII Output:
51 % Ascii Char for 3 (http://www.asciitable.com/)
44 % ...............,
49 % ...............1
13 % ...............carriage return
10
57
44
.......
You almost have it. Just use
charafterfreadto interpret the read bytes as ASCII characters. Also add.'if you want a row vector instead of a column vector: