0

matlab: How to convert a vector of complex double elements to a vector of 24bit (each element)? (using the fact that the real part is 12 bit and the imaginary part 12 bit)

My try:

fileOpen=fopen('newFile.txt');
fprintf(fileOpen, '%d,\r\n', real(complexNum)+((imag(complexNum))*(2^12))));
fclose(fileOpen);
tami
  • 45
  • 6
  • 1
    There is no 24-bit numeric type in MATLAB. What exactly is your desired result? Please read [ask] and how to provide a [mcve]. – beaker Jun 04 '17 at 16:44
  • @beaker If I need a data output to be of 24bit, How it can be done? – tami Jun 04 '17 at 17:08
  • 1
    Provide some sample input/s and the expected output in the form of actual numbers – Sardar Usama Jun 04 '17 at 17:18
  • I used your code and it gave me the results you requested. Granted, my input file contained only integers less than 4096 for the real and imaginary parts, and I was expecting an ASCII formatted integer in the range [0,16777215] as output. If your inputs and/or desired outputs are different, you'll have to let us know what those are. – beaker Jun 04 '17 at 17:52

1 Answers1

0

See here for data types: https://www.mathworks.com/help/matlab/numeric-types.html

It appears that there is no support for 24bit operations. Of course, this is to be expected as Matlab is one of those "very" high level languages.

From what you have described. Would you not be better off just doing it from scratch with C language?

Alternatively, check out this link: parse text file in MATLAB

Numbers682
  • 129
  • 1
  • 11