How to do FFT on I,Q data
Afficher commentaires plus anciens
I am Working on a climate orbiter satellite data, from there i have extracted the In_Phase and Quadrature_Phase in decimal form now wanted to do further processing such as FFT , PSD etc.
Can Someone help how to do FFT on that type of data?
Note: I have Very large dataset which is about 144crores but i have divided it into chuncks of files which is about 8 lakh each.
Réponses (1)
Let's assume you have read in data from a two-column file. Column 1 is in-phase, column 2 is quadrature.
N=256;
fs=100e6; % sampling rate (Hz)
t=(0:N-1)/fs;
data=randn(N,2);
Combine the ccolumns to make a single vector of complex numbers
The second column is multiplied by 1i, which is pre-defined as sqrt(-1).
x=data(:,1)+1i*data(:,2);
Now do FFTs or compute power spectra in the usual way. The only difference is that, since x(t) is complex, the FFTs and spectra will not be conjugate-symmetric around the Nyquist frequency. (If you prefer to think of positive and negative frequencies, then the spectra will not be conjugate-symmetric around f=0.)
X=fft(x);
f=(0:N-1)*fs/N;
Plot results
figure; subplot(311)
plot(t,data(:,1),'-r.',t,data(:,2),'-b.'); grid on; xlabel('Time (s)')
legend('In-phase','Quadrature'); title('Time domain');
subplot(312);
plot(f,abs(X),'-g.'); grid on; xlabel('Frequency (Hz)')
ylabel('|X(f)|'); title('FFT')
subplot(313);
plot(f,unwrap(phase(X))*180/pi,'-g.'); grid on; xlabel('Frequency (Hz)')
ylabel('phase(X) (deg)'); title('FFT')
Good luck.
13 commentaires
William Rose
le 30 Oct 2023
findpeaks() is a very useful function with many nice options.
Are you seeking a peak in the spectrum or in the time-domain signal?
Provide a sample file if you wish to see an example of using findpeaks() to find a peak in a spectrum.
silvia cano
le 31 Jan 2024
hi
i have same problemi have In_Phase and Quadrature_Phase i on a file so i try the code above but in my case if i put N=256 , i get the error x and y must have same fdimension. so i change N= length(dataI). I want to know if is possible or i'm doing something wrong
thanks
William Rose
le 1 Fév 2024
Modifié(e) : William Rose
le 1 Fév 2024
Please provide an example of your data. I would not expect your InPhase and Quadrature vectors have different lengths, but if they are different lengths, then you will have to align them correctly and discard non-overlapping elements.
silvia cano
le 1 Fév 2024
i think my data have the same length but if i put N=256 , i get the error x and y must have same fdimension. my doubt if N is the problem or my data
I used N=256 because I needed to generate simulated data as an example.
Since you already have data, use N=length of your data.
load('data.txt');
x=data(:,1)-mean(data(:,1))+1i*(data(:,2)-mean(data(:,2)));
N=length(x);
fs=1e6; % assume sampling rate=1e6 Hz
t=(0:N-1)/fs;
% Compute DFT
X=fft(x);
X=fftshift(X); % shift so freq=0 is in the middle
f=(-N/2:N/2-1)*fs/N;
% Plot results
figure;
subplot(411), plot(t,data(:,1),'-r');
grid on; xlabel('Time (s)'); ylabel('Real'); title('x(t)');
subplot(412), plot(t,data(:,2),'-r');
grid on; xlabel('Time (s)'); ylabel('Imag');
subplot(413); plot(f,abs(X),'-b');
grid on; xlabel('Frequency (Hz)'); ylabel('|X(f)|'); title('FFT')
subplot(414); plot(f,unwrap(phase(X))*180/pi,'-b');
grid on; xlabel('Frequency (Hz)'); ylabel('phase(X)');
The code above runs without errors, using your data.
silvia cano
le 2 Fév 2024
What do I do to not have negative frequencies on the graph and
move freq=0 is in the middle?
William Rose
le 2 Fév 2024
Replace
% Compute DFT
X=fft(x);
X=fftshift(X); % shift so freq=0 is in the middle
f=(-N/2:N/2-1)*fs/N;
with
% Compute DFT
X=fft(x);
f=(0:N-1)*fs/N;
Good luck.
silvia cano
le 2 Fév 2024
thank you so much , another question , if i nedd to plot FFt on axis y and number of samples on x axis ?
William Rose
le 3 Fév 2024
silvia cano
le 12 Fév 2024
hi i have a csv data , with magnitude and number of samples , but if i want to plot magnitude on y axis and distance on x axis , what is the relation between samples and distance
William Rose
le 14 Fév 2024
@silvia cano, I have no idea.
William Rose
le 15 Fév 2024
@silvia cano, since you are asking a new question,
I recommend that you post your question as a new quesiton on Matlab Answers. Include the data that you have that relates to range.
Catégories
En savoir plus sur Multirate Signal Processing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

