Power Spectral Density of a bipolar digital signal

5 ビュー (過去 30 日間)
Vlad Eusebiu Popa
Vlad Eusebiu Popa 2021 年 5 月 28 日
編集済み: MULI 2024 年 5 月 26 日
I am having a difficult time trying to plot the power spectral density of a bipolar digital signal with random values, based on an array. For example:
signal=[0 -1 1 0 1 -1];
Then I create a time vector based on a transfer rate of a specified value like this:
D=160000 % rate transfer of 160Kbps
t=[0:1/D:length(signal)/D];
And I plot the signal like this:
stairs(t,signal);
My signal looks like this :
My question is what should I do to be able to represent the power spectral density of such a signal? Is there a more direct way in Matlab than it would be by implementing all kinds of formulas? In theory, my plot should look roughly like this:
Thanks in advance!

回答 (1 件)

MULI
MULI 2024 年 5 月 26 日
編集済み: MULI 2024 年 5 月 26 日
Hi Vlad,
I understand you need to plot power spectral density. You may use `pwelch` function that calculates the power spectral density (PSD) of a signal.
`pwelch` divides the signal into small sections or windows and calculates the Fourier transform of each window to see what frequencies are present in that section and then it averages these Fourier transforms together to get a smoother estimate of the signal's frequency content.
Below code shows the calculation of ‘PSD’ of signal.
% Define the signal
signal = [0 -1 1 0 1 -1];
% Define the transfer rate
D = 160000; % Transfer rate of 160 Kbps
% Generate the time vector
t = 0:1/D:(length(signal)-1)/D;
% Plot the digital signal
figure;
stairs(t, signal);
xlabel('Time (s)');
ylabel('Amplitude');
title('Digital Signal');
% Estimate and plot the power spectral density
window_length = 5; % Use a smaller window length
overlap_length = []; % Set overlap length to half of the window length
[power_density, frequencies] = pwelch(signal, window_length, overlap_length, [], D);
figure;
plot(frequencies, power_density);
xlabel('Frequency (Hz)');
ylabel('Power Spectral Density');
title('Power Spectral Density of Digital Signal');
You may refer this documentation link for more information and examples related to ‘pwelch’ function.

カテゴリ

Help Center および File ExchangeParametric Spectral Estimation についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by