Home > vbmeg > external > mne > fiff_write_complex.m

fiff_write_complex

PURPOSE ^

SYNOPSIS ^

function fiff_write_complex(fid,kind,data)

DESCRIPTION ^

 fiff_write_complex(fid,kind,data)
 
 Writes a single-precision complex tag to a fif file

     fid           An open fif file descriptor
     kind          Tag kind
     data          The data

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function fiff_write_complex(fid,kind,data)
0002 %
0003 % fiff_write_complex(fid,kind,data)
0004 %
0005 % Writes a single-precision complex tag to a fif file
0006 %
0007 %     fid           An open fif file descriptor
0008 %     kind          Tag kind
0009 %     data          The data
0010 %
0011 
0012 %
0013 %   Author : Matti Hamalainen, MGH Martinos Center
0014 %   License : BSD 3-clause
0015 %
0016 %   Revision 1.1  2006/09/23 14:43:56  msh
0017 %   Added routines for writing complex and double complex matrices.
0018 %   Added routine for writing double-precision real matrix.
0019 %
0020 %
0021 
0022 me='MNE:fiff_write_complex';
0023 
0024 if nargin ~= 3
0025         error(me,'Incorrect number of arguments');
0026 end
0027 
0028 FIFFT_COMPLEX_FLOAT=20;
0029 FIFFV_NEXT_SEQ=0;
0030 nel=numel(data);
0031 datasize=2*nel*4;
0032 count = fwrite(fid,int32(kind),'int32');
0033 if count ~= 1
0034     error(me,'write failed');
0035 end
0036 count = fwrite(fid,int32(FIFFT_COMPLEX_FLOAT),'int32');
0037 if count ~= 1
0038     error(me,'write failed');
0039 end
0040 count = fwrite(fid,int32(datasize),'int32');
0041 if count ~= 1
0042     error(me,'write failed');
0043 end
0044 count = fwrite(fid,int32(FIFFV_NEXT_SEQ),'int32');
0045 if count ~= 1
0046    error(me,'write failed');
0047 end
0048 for k = 1:nel
0049    count = fwrite(fid,real(data(k)),'single');
0050    if count ~= 1
0051       error(me,'write failed');
0052    end
0053    count = fwrite(fid,imag(data(k)),'single');
0054    if count ~= 1
0055       error(me,'write failed');
0056    end
0057 end
0058 return;
0059

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