Power Spectral density plot in a certain frequency range
显示 更早的评论
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.
回答(1 个)
Star Strider
2017-8-4
h1 = plot(Hpsd);
set(h1,'Color','b')
axis([0 1E+4 ylim])
2 个评论
Jose Manuel Gomez Guzman
2017-8-4
Star Strider
2017-8-4
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
