%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% saveRawFloat save a matlab matrix to a binary file for export.
% Input : - mat : matrix to export in a binary file.
% - nomfichier : file name of the futur binary file.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function saveRawFloat(mat, nomfichier)
%saveRawFloat(zeros(4), '../tmp/test.raw')
% Compute number of values, we want to save
nb=1;
for i=1:size(size(mat),2)
nb=nb*size(mat,i);
end
% Open the file
fid = fopen(nomfichier, 'wb');
% Save the number of elements
fwrite(fid, nb, 'uint32'); % il faudra verifier l'endianess...
% Transpose matrix to save data line after line.
% Data are saved in simple precision floating point numbers 32 bits.
fwrite(fid, mat', 'float');
fclose (fid);