FFT and spectrogram on I-Q data

조회 수: 31 (최근 30일)
Meghna Roy Chowdhury
Meghna Roy Chowdhury 2023년 10월 12일
댓글: Paul 2023년 10월 17일
I have an FFT and spectrogram genertated using the follwoing code:
%% fft data generation
Fs = 4e6;
Ns=4e6;
freq=-Fs/2:Fs/Ns:(Fs/2-(Fs/Ns));
amp=10*log10(abs(fft(s(1:Ns),Ns))/Ns);
P=abs(fft(s(1:Ns),Ns))/Ns;
figure(1)
plot((freq+741.5e6),fftshift(P));
%% spectrogram
figure(2);
Nx=4e5;
nsc = floor(Nx/4.5);
nov = floor(nsc/2);
nff = max(256,2^nextpow2(nsc));
spectrogram(s,kaiser(nsc,5.66),nov,nff,Fs, 'MinThreshold',-140);
The output looks like this:
However, I think the spectrogram is wrong:
  1. The frequency axis does not look right
  2. The FFT does not correspond to the spectrogram
Can someone please help me understand the spectrogram with a correct code?
I am using I-Q data (un01)
file = 'un01';
f=fopen(file,'rb');
values = fread(f, Inf,'float');
I=values(1:2:length(values));
Q=values(2:2:length(values));
s=I+1i*Q;
  댓글 수: 9
Meghna Roy Chowdhury
Meghna Roy Chowdhury 2023년 10월 17일
편집: Meghna Roy Chowdhury 2023년 10월 17일
file = 'un01';
f=fopen(file,'rb');
values = fread(f, Inf,'float');
I=values(1:2:length(values));
Q=values(2:2:length(values));
s=I+1i*Q;
fs = 4e6;
Ns=4e6; %BW
figure(1)
total_duration = length(s) / fs;
t1=0:(1/fs):total_duration - 1/fs;
figure(1)
plot(t1,s)
>> numel(s)
ans =
35067267
Paul
Paul 2023년 10월 17일
I'm having lots of trouble reading in the data. Every time I try it, values has a different number of elements that aren't close to what you're showing. Don't know why this is a problem. Wish I could be of more help.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 10월 13일
Here is how the power spectrum can be computed & plotted:
f = fopen(websave('uni01','https://drive.google.com/file/d/1IjKADYLo4sBOsPXw7TqPOWfgOaRWqgdo/view?usp=sharing'),'rb');
values = fread(f, Inf,'float');
I=values(1:2:length(values)-1);
Q=values(2:2:length(values));
X=I+1i*Q;
Fs = 4e6;
%% spectrogram
figure(2);
[Power, Freq, Time] = pspectrum(X, Fs, 'spectrogram');
waterfall(Freq,Time, Power')
wtf = gca;
wtf.XDir = 'reverse';
view([30 45])
xlabel('Frequency (Hz)')
ylabel('Time (seconds)')

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by