0001 function fiff_write_float_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
0024
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