In MATLAB, see fopen( ) and fwrite( ) for writing out binary files. For R2018a and later, your IQData will already be in interleaved format so you can write directly, but you may need this helper routine:
https://www.mathworks.com/matlabcentral/fileexchange/77530-freadcomplex-and-fwritecomplex
For R2017b and earlier you would need to copy the data to get it in interleaved format before you did the writing. E.g., this would get the real & imag data into interleaved format (as a real variable):
Data = [Iwave;Qwave];
Then write Data to the output file. In fact, if you were not worried about that extra data copy, this interleaved Data method will work in all versions of MATLAB.
For conversion to 16-bit floating point, some options are:
Half Precision: Use the MATLAB function half( ) to convert from double to half precision (R2018b or later).
https://www.mathworks.com/help/fixedpoint/ref/half.html
If you have R2018a or earlier you will have to convert to half precision manually. C Code to do this is given here:
https://www.mathworks.com/matlabcentral/fileexchange/23173-ieee-754r-half-precision-floating-point-converter
bfloat16: There is no official MATLAB support for this yet. A simple truncated method to get you close (i.e., without the round-to-even and without NaN checking) would be to convert to single precision and then pick off the most significant 16-bits for writing. E.g., something like
u16 = typecast(single(Data),'uint16');
b16 = u16(1:2:end);
Then write b16 to your binary file.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…