Converting complex int16 matrix to 32 bit floating points(or double)

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

Thanks for comment but somehow it corrupts the signal. It should be Wi-Fi signal,but it is not in the plot. So isn't there any other way to convert int16 to double in MATLAB?
thanks
Actually I want my data to be scaled(normalized) to the range of -1..1 as complex numbers
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?

Sign in to comment.

Answers (1)

complex( double(real(arr)) ./ 65535 * 2 - 1, ...
double(imag(arr)) ./ 65535 * 2 - 1)

10 Comments

hi, thanks for your answer, it seems to be the same as doing double(arr), there is still something wrong with the signal shape.
Can you attach the data, and attach a picture of what you expect the signal to look like?
Hi, here is one frame in mat file. It is a WiFi signal so it should look like the patterns in the attached picture. It can be a bit changed because of noise but I am expecting the patterns to be similar but here not. Thanks for your help
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 ?
Hi, you are right it shows features as wifi signal but it s not actually. I did not create the data therefore i don' know whether it is constellation encoded. I did not tried those things. You mean, the data should be first demodulated?
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
I found how the signal is stored. It is commented like this:
"...we store the rx_signal as int16 values
% max((rx_signal{1}(1,:))-double(int16((rx_signal{1}(1,:))*(2^15)))/(2^15))
rx_signal = int16(reshape(rx_signal,1,[])*(2^15));
now how can I convert it back to double?
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.
It did not help me unfortunately there must be something else. Thank you very much for your time and valuable information
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.

Sign in to comment.

Tags

Asked:

on 25 Oct 2017

Commented:

on 28 Oct 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!