Plotting FFT of several data sets (signals) of same length, in the same graph
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Muhammad Shafiq
le 12 Sep 2018
Commenté : Muhammad Shafiq
le 16 Sep 2018
I have a data of several thousands samples (say 60000), the sampling frequency is given (1 MHz). I want to divide the data in equal frames, each of 500 samples that makes 120 frames, then plot all those (120) frames on the same graph to compare them. I want to plot in time domain and frequency domain. I have been able to do the time domain plot but I don’t know how to do the frequency domain plot of all of the signals in the same graph. Looking forward for the help. Thanks
2 commentaires
dpb
le 12 Sep 2018
Might look at waterfall plot.
I don't know what you mean as far as "in the same graph" when mixing time and frequency domains??? Can you show a representative plot of what you'd like yours to look like?
Réponse acceptée
Aquatris
le 12 Sep 2018
You put all of the signals you want in a matrix (each column is a different partition of the signal);
data = rand(60000,1); % replace with your data
y = [];
for i = 1:120
y(:,i) = data((i-1)*500+1:(i)*500);;
end
% perform the fft as;
L = 500;
Y = fft(y);
P2 = abs(Y/L);
P1 = P2(1:L/2+1,:);
P1(2:end-1,:) = 2*P1(2:end-1,:);
% obtain frequency matrix;
Fs = 1e3; % sampling frequency
f = Fs*(0:(L/2))/L;
% plot frequency domain
figure(1)
semilogy(f,P1)
% plot time domain
figure(2)
plot([1:L]/Fs,y)
Make sure you understand what is done in each step and if you have questions, feel free to ask.
Plus de réponses (1)
Aquatris
le 16 Sep 2018
y = [] just makes y an empty matrix. It is not a necessary code. I include it in the off chance that you had a variable named y in your code. That line would delete any contents of previously assigned y variable values
Voir également
Catégories
En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!