0001 function [nvar, names, types] = nex_info(filename)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 if(nargin ~= 1)
0016 disp('1 input arguments are required')
0017 return
0018 end
0019
0020 if(isempty(filename))
0021 [fname, pathname] = uigetfile('*.nex', 'Select a Nex file');
0022 filename = strcat(pathname, fname);
0023 end
0024
0025 fid = fopen(filename, 'r');
0026 if(fid == -1)
0027 disp('cannot open file');
0028 return
0029 end
0030
0031 disp(strcat('file = ', filename));
0032 magic = fread(fid, 1, 'int32');
0033 version = fread(fid, 1, 'int32');
0034 comment = fread(fid, 256, 'char');
0035 freq = fread(fid, 1, 'double');
0036 tbeg = fread(fid, 1, 'int32');
0037 tend = fread(fid, 1, 'int32');
0038 nvar = fread(fid, 1, 'int32');
0039 fseek(fid, 260, 'cof');
0040 disp(strcat('version = ', num2str(version)));
0041 disp(strcat('frequency = ', num2str(freq)));
0042 disp(strcat('duration (sec) = ', num2str((tend - tbeg)/freq)));
0043 disp(strcat('number of variables = ', num2str(nvar)));
0044 names = zeros(1, 64);
0045 types=zeros(nvar);
0046 for i=1:nvar
0047 types(i) = fread(fid, 1, 'int32');
0048 var_version = fread(fid, 1, 'int32');
0049 names(i, :) = fread(fid, [1 64], 'char');
0050 dummy = fread(fid, 128+8, 'char');
0051 end
0052 names = char(names);
0053 fclose(fid);