0001 function [nch, npoints, freq, d] = ddt(filename)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 if(nargin ~= 1)
0016 disp('1 input argument is required')
0017 return
0018 end
0019 nch = 0;
0020 npoints = 0;
0021
0022 if(isempty(filename))
0023 [fname, pathname] = uigetfile('*.ddt', 'Select a ddt file');
0024 filename = strcat(pathname, fname);
0025 end
0026 fid = fopen(filename, 'r');
0027 if(fid == -1)
0028 disp('cannot open file');
0029 return
0030 end
0031 disp(strcat('file = ', filename));
0032 version = fread(fid, 1, 'int32');
0033 dataoffset = fread(fid, 1, 'int32');
0034 freq = fread(fid, 1, 'double');
0035 nch = fread(fid, 1, 'int32');
0036
0037 fseek(fid, 0, 1);
0038 fsize = ftell(fid);
0039 frewind(fid);
0040 fseek(fid, dataoffset, 0);
0041 npoints = (fsize - dataoffset)/(nch*2);
0042 d = fread(fid, [nch npoints], 'int16');
0043
0044 fclose(fid);