Home > vbmeg > external > mne > fiff_write_float_matrix.m

fiff_write_float_matrix

PURPOSE ^

SYNOPSIS ^

function fiff_write_float_matrix(fid,kind,mat)

DESCRIPTION ^

 fiff_write_float_matrix(fid,kind,mat)
 
 Writes a single-precision floating-point matrix tag

     fid           An open fif file descriptor
     kind          The tag kind
     mat           The data matrix

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function fiff_write_float_matrix(fid,kind,mat)
0002 %
0003 % fiff_write_float_matrix(fid,kind,mat)
0004 %
0005 % Writes a single-precision floating-point matrix tag
0006 %
0007 %     fid           An open fif file descriptor
0008 %     kind          The tag kind
0009 %     mat           The data matrix
0010 %
0011 
0012 %
0013 %
0014 %   Author : Matti Hamalainen, MGH Martinos Center
0015 %   License : BSD 3-clause
0016 %
0017 %   Revision 1.3  2006/04/23 15:29:40  msh
0018 %   Added MGH to the copyright
0019 %
0020 %   Revision 1.2  2006/04/10 23:26:54  msh
0021 %   Added fiff reading routines
0022 %
0023 %   Revision 1.1  2005/12/05 16:01:04  msh
0024 %   Added an initial set of fiff writing routines.
0025 %
0026 %
0027 
0028 me='MNE:fiff_write_float_matrix';
0029 
0030 if nargin ~= 3
0031    error(me,'Incorrect number of arguments');
0032 end
0033 
0034 if length(size(mat)) ~= 2
0035    error(me,'Input should be a two-dimensional matrix');
0036 end
0037 
0038 FIFFT_FLOAT  = 4;
0039 FIFFT_MATRIX = bitshift(1,30);
0040 FIFFT_MATRIX_FLOAT = bitor(FIFFT_FLOAT,FIFFT_MATRIX);
0041 FIFFV_NEXT_SEQ=0;
0042 
0043 datasize = 4*numel(mat) + 4*3;
0044 
0045 count = fwrite(fid,int32(kind),'int32');
0046 if count ~= 1
0047     error(me,'write failed');
0048 end
0049 count = fwrite(fid,int32(FIFFT_MATRIX_FLOAT),'int32');
0050 if count ~= 1
0051     error(me,'write failed');
0052 end
0053 count = fwrite(fid,int32(datasize),'int32');
0054 if count ~= 1
0055     error(me,'write failed');
0056 end
0057 count = fwrite(fid,int32(FIFFV_NEXT_SEQ),'int32');
0058 if count ~= 1
0059     error(me,'write failed');
0060 end
0061 count = fwrite(fid,single(mat'),'single');
0062 if count ~= numel(mat)
0063     error(me,'write failed');
0064 end
0065 dims(1) = size(mat,2);
0066 dims(2) = size(mat,1);
0067 dims(3) = 2;
0068 count = fwrite(fid,int32(dims),'int32');
0069 if count ~= 3
0070     error(me,'write failed');
0071 end
0072 
0073 return;
0074

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005