ddt

PURPOSE ^

ddt(filename) Read data from a .ddt file

SYNOPSIS ^

function [nch, npoints, freq, d] = ddt(filename)

DESCRIPTION ^

 ddt(filename) Read data from a .ddt file

 [nch, npoints, freq, d] = ddt(filename)

 INPUT:
   filename - if empty string, will use File Open dialog

 OUTPUT:
   nch - number of channels
   npoints - number of data points for each channel
   freq - A/D frequency
   d - [nch npoints] data array

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [nch, npoints, freq, d] = ddt(filename)
0002 % ddt(filename) Read data from a .ddt file
0003 %
0004 % [nch, npoints, freq, d] = ddt(filename)
0005 %
0006 % INPUT:
0007 %   filename - if empty string, will use File Open dialog
0008 %
0009 % OUTPUT:
0010 %   nch - number of channels
0011 %   npoints - number of data points for each channel
0012 %   freq - A/D frequency
0013 %   d - [nch npoints] data array
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);

Generated on Fri 12-Aug-2011 11:36:15 by m2html © 2005