Home > vbmeg > external > mne > fiff_write_double_complex_matrix.m

fiff_write_double_complex_matrix

PURPOSE ^

SYNOPSIS ^

function fiff_write_double_complex_matrix(fid,kind,mat)

DESCRIPTION ^

 fiff_write_double_complex_matrix(fid,kind,mat)

 Writes a double-precision complex 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_double_complex_matrix(fid,kind,mat)
0002 %
0003 % fiff_write_double_complex_matrix(fid,kind,mat)
0004 %
0005 % Writes a double-precision complex 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.1  2006/09/23 14:43:56  msh
0018 %   Added routines for writing complex and double complex matrices.
0019 %   Added routine for writing double-precision real matrix.
0020 %
0021 %
0022 
0023 me='MNE:fiff_write_double_complex_matrix';
0024 
0025 if nargin ~= 3
0026         error(me,'Incorrect number of arguments');
0027 end
0028 
0029 FIFFT_COMPLEX_DOUBLE = 21;
0030 FIFFT_MATRIX  = bitshift(1,30);
0031 FIFFT_MATRIX_COMPLEX_DOUBLE = bitor(FIFFT_COMPLEX_DOUBLE,FIFFT_MATRIX);
0032 FIFFV_NEXT_SEQ=0;
0033 
0034 datasize = 2*8*numel(mat) + 4*3;
0035 
0036 count = fwrite(fid,int32(kind),'int32');
0037 if count ~= 1
0038     error(me,'write failed');
0039 end
0040 count = fwrite(fid,int32(FIFFT_MATRIX_COMPLEX_DOUBLE),'int32');
0041 if count ~= 1
0042     error(me,'write failed');
0043 end
0044 count = fwrite(fid,int32(datasize),'int32');
0045 if count ~= 1
0046     error(me,'write failed');
0047 end
0048 count = fwrite(fid,int32(FIFFV_NEXT_SEQ),'int32');
0049 if count ~= 1
0050    error(me,'write failed');
0051 end
0052 nrow = size(mat,1);
0053 ncol = size(mat,2);
0054 for j = 1:nrow
0055    for k = 1:ncol
0056       count = fwrite(fid,real(mat(j,k)),'double');
0057       if count ~= 1
0058           error(me,'write failed');
0059       end
0060       count = fwrite(fid,imag(mat(j,k)),'double');
0061       if count ~= 1
0062           error(me,'write failed');
0063       end
0064    end
0065 end
0066 dims(1) = size(mat,2);
0067 dims(2) = size(mat,1);
0068 dims(3) = 2;
0069 count = fwrite(fid,int32(dims),'int32');
0070 if count ~= 3
0071     error(me,'write failed');
0072 end
0073 
0074 return;
0075

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