Plotting pwelch PSD manually
7 次查看(过去 30 天)
显示 更早的评论
I'm plotting a pwelch PSD.
From my plot toolbox, I select pwelch (psd). This gives me the figure.
The y-axis values are correct (validating from previous data), but I want the X-axis values to display as frequency (Hz).
After reading the Documentation for 'pwelch' in Help, I compiled this script:
rng default
SR = 10000; % Sample Rate (kHz)
d = 1; % Time duration of data (seconds).
t = 0:1/SR:d-1/SR; % 0:0.0001:0.9999
psd = [avg(1:10000,17), avg(1:10000,21), avg(1:10000,25), avg(1:10000,33), Navg(1:10000,2)]; % Data for sensors (V).
x = psd.^2; % Calculating the Power for the data (V^2).
[pxx,f] = pwelch(x, 5000, 3000, 5000, SR);
plot(f, (20*log10(pxx))) % Using 20*log10 due to source being in volts.
xlim([0 1500]) % Frequency limit on X-axis.
legend('0m', '8m', '16m', '32m', 'BG') % Sensor distance or name.
xlabel('Frequency (Hz)')
ylabel('Magnitude (dB)')
This script gives me the X-axis in frequency, but my Y-axis is not being calculated correcty as it was above. I believe the issue is in my plot(...) line's Y-component.
I'm not familiar with pwelch in MATLAB, what edits would you suggest for my script to calculate and display the PSD with the Y-axis of the top figure and the X-axis of the bottom figure.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Estimation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!