Forums › SM Series Discussions › How to read IQ data I matlab
- This topic has 5 replies, 4 voices, and was last updated 6 years, 9 months ago by
Gary.
- AuthorPosts
- February 19, 2020 at 9:11 am #236372
Kefei Hei
ParticipantI have recorded a data with iq file. But I want to get a series of spectrum for 30s with 1ms sample rate. Because I can not record the spectrum continously in sweep mode, I have to record it in zero band mode. I want to know how to transfer the iq file to a series of spectrum.
February 19, 2020 at 9:40 am #236373
Justin CrooksModeratorKefei,
To convert I/Q data to spectrum, you will need to perform overlapping windowed FFTs. Typically what this looks like, if you are doing a 1024-point complex FFT, is every N samples (for your application this would be every 1 ms), you will take the last 1024 I/Q samples, window them (multiply by a window function, like a flat top or hamming window), and then FFT them to generate a spectrum.
February 19, 2020 at 12:32 pm #236374Kefei Hei
ParticipantJustin,
I still dont know how to process the data. Do you have any demo for it? I think this is also useful for all users. Because we need to use other method to process the data, such as Matlab and Python.
Could you tell us how the Spike does to get the time domain and frequency domain signal.February 19, 2020 at 12:39 pm #236375
AndrewModeratorKefei,
Unfortunately we do not have any examples of performing this type of processing in MATLAB. I would start by learning about FFTs and the role of window functions for the FFT. There is a lot of literature available on the internet on this topic using MATLAB as the programming language. MATLAB has several functions to assist in this type of processing.
Overlapped FFTs as described in Justin’s response are how Spike converts I/Q data into a series of closely spaced spectrums.
Regards,
AndrewFebruary 20, 2020 at 1:25 am #236403Kefei Hei
ParticipantBecasue with Spike and .iq data. The result is very good and we need to do further processing of the data.
February 29, 2020 at 3:57 pm #236549
GaryParticipantHey, Kefei Hei, I may be able to help you (assuming you’ve not already figured it out). I’m using Gnu Octave, not Matlab, but they should be fairly similar. On my computer (an Intel-based system), the Signalhound IQ data shows up as “shorts”.
I created an IQ file called “myFile.iq”. Here’s a short script I created to read in a short bit of data from that IQ file, then generate a simple FFT display (no windowing).
f=fopen('myFile.iq','rb'); % Opens the file to read as binary data. s=fread(f,8192,'short'); % Reads in 8192 samples. % Signalhound IQ data is a stream of I-Q-I-Q... points. % It must be parsed out to properly represent the data. sReal=s(1:2:end); % Set the real points sImag=s(2:2:end); % Set the imaginary points sc=sReal+j*sImag; % Create the actual complex samples frq=20*log10(abs(fft(sc/8192))); % Create FFT frqShift=fftshift(frq); % Shift the horizontal axis so that it displays properly plot(frq)Note that, if I left out the “8192” from the “fread” statement, it would have read all of the data at once.
I tested this, and the spectrum I got was similar to what I got from Spike, so I believe I have the set-up correct.
Hope this helps!
- AuthorPosts
- You must be logged in to reply to this topic.
