MATLAB: How to create a FI variable and write the HEX and BIN values to a text file in MATLAB 7.14 (R2012a)

I am trying to generate a fixed point variable using the FI function. I would like to print the HEX and BIN values associated with the variable to a text file.
How can this be done in MATLAB?

Best Answer

This can be done similar to the following example in MATLAB:
>> My_Var = fi(-1.05, 1, 17, 10);
>> fid = fopen('myData.txt','w');
>> fprintf(fid, '%s', My_Var.hex);
>> fclose(fid);
Please replace "My_Var.hex" with "My_Var.bin" to print the binary values to the text file.