Forums › SM Series Discussions › How to read IQ data I matlab › Reply To: How to read IQ data I matlab
Gary
Hey, 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!
