Converting complex int16 matrix to 32 bit floating points(or double)
Show older comments
Hi everyone, I have matrix which contains 100x1000 int16 values (complex values eg: 128 + 151i). How can I convert the complex values to 32 bit complex floating point or double? When I use conversion like this double(arr) then my signal is not looking like a correct signal. Any help would be appreciated.
Best Regards
Seref
4 Comments
Adam
on 25 Oct 2017
double( arr )
should work fine in theory.
seref
on 25 Oct 2017
seref
on 25 Oct 2017
Adam
on 25 Oct 2017
Whatever you scale it to it won't look any different when you plot it if it is just a constant scale factor.
Which values are giving the 'wrong' answer when converted?
Answers (1)
Walter Roberson
on 25 Oct 2017
complex( double(real(arr)) ./ 65535 * 2 - 1, ...
double(imag(arr)) ./ 65535 * 2 - 1)
10 Comments
seref
on 25 Oct 2017
Walter Roberson
on 25 Oct 2017
Can you attach the data, and attach a picture of what you expect the signal to look like?
seref
on 26 Oct 2017
Walter Roberson
on 26 Oct 2017
plot(real(rxsignal(1:600)))
and
plot(imag(rxsignal(1:600)))
That portion of the signal shows features sort of like what you are looking for.
My guess is that you are looking at something that is constellation encoded, but I am not sure which QAM it is using. Have you tried using https://www.mathworks.com/help/comm/ref/qamdemod.html or https://www.mathworks.com/help/comm/ref/vitdec.html ?
seref
on 26 Oct 2017
Walter Roberson
on 26 Oct 2017
Yes, you very likely need to demodulate.
There is a table of modulation schemes by WiFi standard at http://rfmw.em.keysight.com/wireless/helpfiles/n7617a/coding_and_modulation.htm . It looks like mostly OFDM is used, except for 802.11b and some forms of 802.11g: those use DSSS
seref
on 26 Oct 2017
Edited: Walter Roberson
on 26 Oct 2017
Walter Roberson
on 26 Oct 2017
The part
double(int16((rx_signal{1}(1,:))*(2^15)))/(2^15))
effectively truncates at 15 bits plus sign.
The max() minus that... well, that cannot possibly produce the results seen in the .mat. If the original data was in the range -1 to +1, then after the double() part it would still be in that range, just with bits after the 15th binary place discarded. Suppose the max of the original data was 1, then when you subtract off the truncated signal, that would give you a range of 1-([-1 to 1]), which would be a range of 2 to 0. Multiply that by 2^15 and truncate as 15 data bits is going to give you a range of 0 to 32767 with the 32767 used for any value that was originally negative. The only values that can be negative in the outcome would be values very very close to the maximum in the data, and then only because using int16() to truncate the data rounds the results. For example .98766 becomes the slightly larger 0.9876708984375 after the truncation process, leading to a max() minus value of -0.3571200000005774199962615966796875 -- though it might be possible to show that even those values would map to 0 in the later int16 step.
seref
on 28 Oct 2017
Walter Roberson
on 28 Oct 2017
Ah, the max() line is commented out, and I mis-counted brackets before... it is just noise for the purposes of the discussion.
Okay, so we are back to the idea that the data must represent an encoding of the actual signal, and that you will need to demodulate.
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!