Implementing the PSD from its definition

  • Thread starter Thread starter james1234
  • Start date Start date
  • Tags Tags
    definition psd
Click For Summary
SUMMARY

This discussion focuses on implementing the Power Spectral Density (PSD) for a deterministic signal using MATLAB. The user provides a MATLAB script that computes the Fourier transform and attempts to plot the PSD over the frequency range of 0.1 to 5 rad/s. Key issues arise regarding the interpretation of energy as a scalar rather than a function of frequency, leading to confusion about the expected output of the PSD. The user seeks clarification on ensuring the PSD is a real-valued, nonnegative function of omega.

PREREQUISITES
  • Understanding of MATLAB programming and syntax
  • Knowledge of Fourier transforms and their applications in signal processing
  • Familiarity with power spectral density concepts
  • Basic grasp of numerical integration techniques, specifically the trapezoidal rule
NEXT STEPS
  • Review MATLAB's FFT function for efficient computation of the Fourier transform
  • Explore the concept of windowing in signal processing to improve PSD estimation
  • Learn about the relationship between energy and power in signals
  • Investigate the use of Welch's method for estimating the PSD
USEFUL FOR

Signal processing engineers, MATLAB users, and researchers working with deterministic signals and power spectral density analysis will benefit from this discussion.

james1234
Messages
19
Reaction score
0
I would be grateful for some direction on this.

I wish to implement the following -
Given a deterministic signal (the feedback signal of a closed-loop stable system) I would like to plot the power spectral density.
The definition I am working with is this:

upload_2015-1-19_20-0-26.png


Implementation (MATLAB):

% Given a signal the plot of the power spectral density over the frequency range 0.1-5 rad/s is given by
% The continuous time Fourier transform

upload_2015-1-19_20-4-34.png


w=.1:.1:5; % 0.1 to 5 rad/s (frequency range of interest)

% Compute the transform
for ii=1:50 % For each frequency increment (50 samples over the interval 0.1:0.1:5)

yy1=um.*sin(w(ii)*t) % where t is a vector of dimension [1, 3610] and um is the time series in question
yy2=um.*cos(w(ii)*t) %

% the intergral
yi1=trapz(t,yy1);
yi2=trapz(t,yy2);

% square of the Fourier transform i.e. |X(omega)|^2
trans(ii)=(yi1^2+yi2^2);

end

figure(1)
plot(w, trans) % |X(omega)|^2

upload_2015-1-19_20-13-33.png
% For a deterministic signal no need to compute the expected value, the power of the signal is instead given by

upload_2015-1-19_20-9-0.png


% Energy: integral of the square of the Fourier transform wrt to frequency
energy = trapz(w, trans);
figure(2)
plot(w,energy) % sadly things have gone awry HERE!

upload_2015-1-19_20-14-39.png
% Power
power = energy / t(end); % where t(end) is the duration of the signal in question
figure(3)
plot(w, power)
The PSD should be a real valued nonnegative function of omega not a constant. Any prompts would be much appreciated!
 

Attachments

  • upload_2015-1-19_20-8-29.png
    upload_2015-1-19_20-8-29.png
    582 bytes · Views: 526
The energy of a signal is a single number - a scalar. It is not a function of frequency. After all you integrated over frequency already in order to compute it! Look at numel(energy) and you should see that it is has 1 element.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
9
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
7
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K