% Write 'x' to file 'fname' in the Rigol AWG '.RAF' format:
% unsigned 16-bit values in LittleEndian byte order.  Values of x
% should range from 0 to 1.

function rafwrite(fname,x)
   fid = fopen ( fname, 'w' ) ;
   fwrite(fid, floor(x.*(2^14-1)), 'uint16', 'ieee-le' ) ;
   fclose(fid) ;
end
