0001 function fiff_write_int_matrix(fid,kind,mat)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 me='MNE:fiff_write_int_matrix';
0024
0025 if nargin ~= 3
0026 error(me,'Incorrect number of arguments');
0027 end
0028
0029 if length(size(mat)) ~= 2
0030 error(me,'Input should be a two-dimensional matrix');
0031 end
0032
0033 FIFFT_INT = 3;
0034 FIFFT_MATRIX = bitshift(1,30);
0035 FIFFT_MATRIX_INT = bitor(FIFFT_INT,FIFFT_MATRIX);
0036 FIFFV_NEXT_SEQ=0;
0037
0038 datasize = 4*numel(mat) + 4*3;
0039
0040 count = fwrite(fid,int32(kind),'int32');
0041 if count ~= 1
0042 error(me,'write failed');
0043 end
0044 count = fwrite(fid,int32(FIFFT_MATRIX_INT),'int32');
0045 if count ~= 1
0046 error(me,'write failed');
0047 end
0048 count = fwrite(fid,int32(datasize),'int32');
0049 if count ~= 1
0050 error(me,'write failed');
0051 end
0052 count = fwrite(fid,int32(FIFFV_NEXT_SEQ),'int32');
0053 if count ~= 1
0054 error(me,'write failed');
0055 end
0056 count = fwrite(fid,int32(mat'),'int32');
0057 if count ~= numel(mat)
0058 error(me,'write failed');
0059 end
0060 dims(1) = size(mat,2);
0061 dims(2) = size(mat,1);
0062 dims(3) = 2;
0063 count = fwrite(fid,int32(dims),'int32');
0064 if count ~= 3
0065 error(me,'write failed');
0066 end
0067
0068 return;
0069