Power Spectral density plot in a certain frequency range
Afficher commentaires plus anciens
Hi guys,
I want to do a Power Spectral density spectrum of a given txt file (170619pulser1_1_trace.txt). The code that I use is the following:
A = load('170619pulser1_1_trace.txt');
rawData = length(A);
% Power Spectral density of raw data %
Fs = 25e6; % Sampling frequency
Ts = 1/Fs;
N = rawData;
tmax=(N-1)*Ts;
t = 0:Ts:tmax;
nfft = 2^nextpow2(length(A));
Pxx = abs(fft(A,nfft)).^2/length(A)/Fs;
Hpsd = dspdata.psd(Pxx(1:length(Pxx)/2),'Fs',Fs);
h1 = plot(Hpsd);
set(h1,'Color','b')
This gaves me the following plot which is esentially fine:

Now the point is the following: is there any way to make the same plot but just in a certain frequency range, and not in the whole Fs/2 range?. Let´s say that I´m just interested in the region [0, 10 KHz], is there any way to make the dsp in this range?. I mean, apart from using the "zoom in" tool :-).
Many thanks, Jose Manuel.
Réponses (1)
Star Strider
le 4 Août 2017
h1 = plot(Hpsd);
set(h1,'Color','b')
axis([0 1E+4 ylim])
2 commentaires
Jose Manuel Gomez Guzman
le 4 Août 2017
Star Strider
le 4 Août 2017
Your data are what they are. If you have 1000 points between 0 and 1.2E+7 Hz, and they are evenly spaced, the points are 1.2E+4 Hz apart. A window of 1.0E+4 Hz does not have the resolution to show anything other than the straight line that you got.
You can increase the frequency resolution by increasing ‘nfft’, and perhaps using resample to increase the sampling frequency. I leave you to experiment with those options.
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!
