eeg_write - Write matrix of EEG data into binary file Useage: eeg_write(file,data,PRECISION) where: 'file' is the path + filename, eg "c:\data.dat" 'data' is a matlab variable 'PRECISION' is a binary format ('double' default, see fread) comment: Uses the fwrite method to output both 'size(data)' and data. The size(data) integers are written first and used by 'eeg_load' to determine the size of the data matrix. All files are 'ieee-le'.
0001 function eeg_write(file,data,PRECISION) 0002 0003 % eeg_write - Write matrix of EEG data into binary file 0004 % 0005 % Useage: eeg_write(file,data,PRECISION) 0006 % 0007 % where: 'file' is the path + filename, eg "c:\data.dat" 0008 % 'data' is a matlab variable 0009 % 'PRECISION' is a binary format ('double' default, see fread) 0010 % 0011 % comment: Uses the fwrite method to output both 'size(data)' and 0012 % data. The size(data) integers are written first and used 0013 % by 'eeg_load' to determine the size of the data matrix. 0014 % All files are 'ieee-le'. 0015 % 0016 0017 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:33 $ 0018 0019 % Licence: GNU GPL, no express or implied warranties 0020 % History: 07/2001, Darren.Weber_at_radiology.ucsf.edu 0021 % 0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0023 0024 if ~exist('PRECISION','var'), PRECISION = 'double'; end 0025 0026 [path,name,ext] = fileparts(file); 0027 file = fullfile(path,[name ext]); 0028 0029 fid = fopen(file,'w','ieee-le'); 0030 0031 % Write magicN data file size 0032 magicN = size(data); 0033 count = fwrite(fid,magicN,'int'); 0034 0035 % Write the rest of the data 0036 count = fwrite(fid,data,PRECISION); fclose(fid); 0037 0038 fprintf('EEG_WRITE: Wrote %d bytes to:\t%s\n', count, file); 0039 0040 return