필터 지우기
필터 지우기

Plotting pwelch PSD manually

조회 수: 5 (최근 30일)
onamaewa
onamaewa 2019년 3월 28일
편집: onamaewa 2019년 3월 28일
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개)

카테고리

Help CenterFile Exchange에서 Spectral Estimation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by