EXP 10-Analysis of Power Spectral Density
EXP 10-Analysis of Power Spectral Density
AIM:
To compute and analyze the Power Spectral Density (PSD) of random and deterministic signals
using MATLAB and visualize the frequency-domain characteristics using the Signal Processing
Toolbox.
THEORY:
The Power Spectral Density (PSD) shows how the power of a signal or time series is
distributed with frequency. It is useful in analyzing noise, filters, and communication signals.
Common methods:
1
Periodogram: 𝑃(𝑓) = 𝑁 ∣ 𝑋(𝑓) ∣2
Welch’s method: Averaged periodograms with windowing for smoother estimate
MATLAB Tools:
pwelch – Welch's method
periodogram – Basic FFT-based method
psd – (older function)
fft – Manual calculation of PSD
PROCEDURE:
1. Define or generate a time-domain signal (random or deterministic).
2. Use pwelch() or periodogram() to compute PSD.
3. Plot and analyze peak frequencies and bandwidth.
4. Compare different signals or system responses.
LAB MANUAL
PROBLEMS WITH MATLAB CODE
% Compute PSD
figure;
pwelch(x,[],[],[],Fs);
title('PSD of Sinusoidal Signal at 50 Hz');
figure;
subplot(2,1,1); pwelch(x1,[],[],[],Fs); title('PSD of Sine Wave');
subplot(2,1,2); pwelch(x2,[],[],[],Fs); title('PSD of Square Wave');
LAB MANUAL
Problem 4: PSD of Filtered White Noise
clc; clear;
Fs = 1000;
t = 0:1/Fs:2;
x = randn(size(t)); % White noise input
figure;
pwelch(y,[],[],[],Fs);
title('PSD of Filtered White Noise (Low-pass)');
N = length(x);
X = fft(x);
Pxx = (1/(Fs*N)) * abs(X).^2; % Power spectrum
f = (0:N-1)*(Fs/N);
figure;
plot(f, 10*log10(Pxx));
xlim([0 Fs/2]);
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');
title('Manual PSD using FFT');
grid on;
LAB MANUAL
Out put
RESULT:
The PSD of different signals was successfully computed and interpreted using MATLAB
functions like pwelch, periodogram, and FFT.
LAB MANUAL
Problem 6
A variety of toolbox functions generate waveforms. Most require you to begin
with a vector representing a time base. Consider generating data with a 1000
Hz sample frequency, for example. An appropriate time vector is t = (0:0.001:1)'
Matlab code
t = (0:0.001:1)';
y = sin(2*pi*50*t) + 2*sin(2*pi*120*t);
randn('state',0);
yn =y +0.5*randn(size(t));
plot(t(1:50),yn(1:50))
Output
Problem 7
To generate 1.5 seconds of a 50 Hz sawtooth wave with a sample rate of 10 kHz
and plot 0.2 seconds of the generated waveform, use
Matlab code
fs = 10000;
t = 0:1/fs:1.5;
x = sawtooth(2*pi*50*t);
plot(t,x), axis([0 0.2 -1 1])
LAB MANUAL
Output
Problem 8
Aperiodic Waveforms
To compute 2 seconds of a linear chirp signal with a sample rate of 1 kHz, that starts
at DC and crosses 150 Hz at 1 second, use
t = 0:1/1000:2;
y = chirp(t,0,1,150);
specgram(y,256,1000,256,250)
Output
LAB MANUAL
Problem 9
T = 0:1/50E3:10E-3;
D = [0:1/1E3:10E-3;0.8.^(0:10)]';
Y = pulstran(T,D,'gauspuls',10E3,0.5);
plot(T,Y)
Output
LAB MANUAL
Problem 10 Visualization of Dirichlet Functions for Odd and Even Harmonics Using MATLAB
Matlab code
clc; clear;
subplot(2,1,1);
plot(x, y7, 'r', 'LineWidth', 1.5);
title('Dirichlet Function, N = 7');
xlabel('x'); ylabel('diric(x,7)');
grid on;
subplot(2,1,2);
plot(x, y8, 'g', 'LineWidth', 1.5);
title('Dirichlet Function, N = 8');
xlabel('x'); ylabel('diric(x,8)');
grid on;
Output