Wednesday, 17 December 2014

How to plot the frequency spectrum of the IF (intermediate frequency) data of GPS signal, in Matlab?


1. An example is given here.

clc;
clear all;

%Inputs
fName = 'Ifdata.bin'; % input data file

fs = 5e6; %IF data sampling frequency
lenTime = 100; % ms, length of data to be considered

fid = fopen(fName,'rb');

M = lenTime*fs * 1e-3 * 2; %I and Q (complex) values of 16 bits each
data = fread(fid, M,'int16'); % reading from the file. 'int16' is the data type
data = data(1:2:end) + 1i*data(2:2:end); %arranging in complex data format. d = I + j*Q
N = lenTime*fs * 1e-3;
delf = fs / N;
freqInd = -fs/2:delf:(fs/2) - delf;

figure, plot(freqInd, 10*log10(fftshift(abs(fft(data))))); %plot of the spectrum

No comments:

Post a Comment