%Essential_BW_Ex2 % Plot ESD and calculate essential bandwidth of a signal, x(t)
ID: 2290975 • Letter: #
Question
%Essential_BW_Ex2
% Plot ESD and calculate essential bandwidth of a signal, x(t), sampled at
% intervals of dt;
%The example done here is for a signal, x(t) = exp(-2t), but it can be
%easiloy modified for any arbitrary signal, or converted into a function call
%for an arbitrary signal
clc;close all;
%Create sampled x(t)=exp(-t)u(t);
dt=0.01;Fs=1/dt;
t = [0:dt:5];
x = exp(-2*t);
%Compute and plot ESD
Nfft = 2^(nextpow2(length(x))+2); %Choose a FFT size, N = (Nearest power of 2) greater than length of x(t)
Xf = (1/sqrt(Nfft))*fft(x,Nfft); %Note: Normalization by sqrt(N) is necessary to satisfy Parseval's relation for DFT
Xf2 = abs(Xf).^2; %Xf2 = Energy spectral density of x(t)
freq = [0:(Nfft/2)-1]*Fs/Nfft; %This creates a vector of fequency points
EXf = sum(Xf2); %Exf = Energy using freq-domain integration of ESD
figure(1)
subplot(211)
plot(freq,Xf2(1:Nfft/2));title('Energy spectral density (ESD) of x(t) ')
xlabel('frequency in Hz ');
ylabel('ESD of exp(-2t) ')
subplot(212)
plot(freq(1:1000),Xf2(1:1000));title('Low frequency section of Energy spectral density (ESD) of x(t) ')
xlabel('frequency in Hz ');
ylabel('ESD of exp(-2t) ')
%Compute and print Essential BW of a desired percentage
p = input('Enter desired percentage of Essential Bandwidth = ');
pEXf = (p/100)*EXf;
PartialSum_Xf2=0;
for k = 1:Nfft/2
if (k==1)
PartialSum_Xf2 = PartialSum_Xf2 + Xf2(k); %Note: k=1 represents zero frequency or DC value
else
PartialSum_Xf2 = PartialSum_Xf2 + 2*Xf2(k); %Note: ESD is a symmetric function of frequency
end
if (PartialSum_Xf2 >= pEXf)
break
end
end
Essential_BW_in_Hz = freq(k)
Explanation / Answer
code for x(t) = u(t-3)-u(t-4)
----------------------------------------------
%Essential_BW_Ex2
% Plot ESD and calculate essential bandwidth of a signal, x(t), sampled at
% intervals of dt;
%The example done here is for a signal, x(t) = exp(-2t), but it can be
%easiloy modified for any arbitrary signal, or converted into a function call
%for an arbitrary signal
clc;close all;
syms t
%Create sampled x(t)=exp(-t)u(t);
dt=0.01;Fs=1/dt;
t = [0:dt:5];
x = heaviside(t-3)-heaviside(t-4);
%Compute and plot ESD
Nfft = 2^(nextpow2(length(x))+2); %Choose a FFT size, N = (Nearest power of 2) greater than length of x(t)
Xf = (1/sqrt(Nfft))*fft(x,Nfft); %Note: Normalization by sqrt(N) is necessary to satisfy Parseval's relation for DFT
Xf2 = abs(Xf).^2; %Xf2 = Energy spectral density of x(t)
freq = [0:(Nfft/2)-1]*Fs/Nfft; %This creates a vector of fequency points
EXf = sum(Xf2); %Exf = Energy using freq-domain integration of ESD
figure(1)
subplot(211)
plot(freq,Xf2(1:Nfft/2));title('Energy spectral density (ESD) of x(t) ')
xlabel('frequency in Hz ');
ylabel('ESD of exp(-2t) ')
subplot(212)
plot(freq(1:1000),Xf2(1:1000));title('Low frequency section of Energy spectral density (ESD) of x(t) ')
xlabel('frequency in Hz ');
ylabel('ESD of exp(-2t) ')
%Compute and print Essential BW of a desired percentage
p = input('Enter desired percentage of Essential Bandwidth = ');
pEXf = (p/100)*EXf;
PartialSum_Xf2=0;
for k = 1:Nfft/2
if (k==1)
PartialSum_Xf2 = PartialSum_Xf2 + Xf2(k); %Note: k=1 represents zero frequency or DC value
else
PartialSum_Xf2 = PartialSum_Xf2 + 2*Xf2(k); %Note: ESD is a symmetric function of frequency
end
if (PartialSum_Xf2 >= pEXf)
break
end
end
Essential_BW_in_Hz = freq(k)
----------------------------------------------------------------
command Window:
Enter desired percentage of Essential Bandwidth = 90
Essential_BW_in_Hz =
0.7813
------------------------------------------------------------------------------------
code for x(t) =u(t-3)-u(t-3.25)
----------------------------------------------------------------
%Essential_BW_Ex2
% Plot ESD and calculate essential bandwidth of a signal, x(t), sampled at
% intervals of dt;
%The example done here is for a signal, x(t) = exp(-2t), but it can be
%easiloy modified for any arbitrary signal, or converted into a function call
%for an arbitrary signal
clc;close all;
syms t
%Create sampled x(t)=exp(-t)u(t);
dt=0.01;Fs=1/dt;
t = [0:dt:5];
x = heaviside(t-3)-heaviside(t-3.25);
%Compute and plot ESD
Nfft = 2^(nextpow2(length(x))+2); %Choose a FFT size, N = (Nearest power of 2) greater than length of x(t)
Xf = (1/sqrt(Nfft))*fft(x,Nfft); %Note: Normalization by sqrt(N) is necessary to satisfy Parseval's relation for DFT
Xf2 = abs(Xf).^2; %Xf2 = Energy spectral density of x(t)
freq = [0:(Nfft/2)-1]*Fs/Nfft; %This creates a vector of fequency points
EXf = sum(Xf2); %Exf = Energy using freq-domain integration of ESD
figure(1)
subplot(211)
plot(freq,Xf2(1:Nfft/2));title('Energy spectral density (ESD) of x(t) ')
xlabel('frequency in Hz ');
ylabel('ESD of exp(-2t) ')
subplot(212)
plot(freq(1:1000),Xf2(1:1000));title('Low frequency section of Energy spectral density (ESD) of x(t) ')
xlabel('frequency in Hz ');
ylabel('ESD of exp(-2t) ')
%Compute and print Essential BW of a desired percentage
p = input('Enter desired percentage of Essential Bandwidth = ');
pEXf = (p/100)*EXf;
PartialSum_Xf2=0;
for k = 1:Nfft/2
if (k==1)
PartialSum_Xf2 = PartialSum_Xf2 + Xf2(k); %Note: k=1 represents zero frequency or DC value
else
PartialSum_Xf2 = PartialSum_Xf2 + 2*Xf2(k); %Note: ESD is a symmetric function of frequency
end
if (PartialSum_Xf2 >= pEXf)
break
end
end
Essential_BW_in_Hz = freq(k)
------------------------------------------------------------------------------------
command Window:
Enter desired percentage of Essential Bandwidth = 9
Essential_BW_in_Hz =
0.1953
-----------------------------------------------------------------------------
for x(t) = triangle(t-3.5)
--------------------------------------------------------------------------------
%Essential_BW_Ex2
% Plot ESD and calculate essential bandwidth of a signal, x(t), sampled at
% intervals of dt;
%The example done here is for a signal, x(t) = exp(-2t), but it can be
%easiloy modified for any arbitrary signal, or converted into a function call
%for an arbitrary signal
clc;close all;
syms t
%Create sampled x(t)=exp(-t)u(t);
dt=0.01;Fs=1/dt;
t = [0:dt:5];
x = sawtooth(t-3.5);
%Compute and plot ESD
Nfft = 2^(nextpow2(length(x))+2); %Choose a FFT size, N = (Nearest power of 2) greater than length of x(t)
Xf = (1/sqrt(Nfft))*fft(x,Nfft); %Note: Normalization by sqrt(N) is necessary to satisfy Parseval's relation for DFT
Xf2 = abs(Xf).^2; %Xf2 = Energy spectral density of x(t)
freq = [0:(Nfft/2)-1]*Fs/Nfft; %This creates a vector of fequency points
EXf = sum(Xf2); %Exf = Energy using freq-domain integration of ESD
figure(1)
subplot(211)
plot(freq,Xf2(1:Nfft/2));title('Energy spectral density (ESD) of x(t) ')
xlabel('frequency in Hz ');
ylabel('ESD of exp(-2t) ')
subplot(212)
plot(freq(1:1000),Xf2(1:1000));title('Low frequency section of Energy spectral density (ESD) of x(t) ')
xlabel('frequency in Hz ');
ylabel('ESD of exp(-2t) ')
%Compute and print Essential BW of a desired percentage
p = input('Enter desired percentage of Essential Bandwidth = ');
pEXf = (p/100)*EXf;
PartialSum_Xf2=0;
for k = 1:Nfft/2
if (k==1)
PartialSum_Xf2 = PartialSum_Xf2 + Xf2(k); %Note: k=1 represents zero frequency or DC value
else
PartialSum_Xf2 = PartialSum_Xf2 + 2*Xf2(k); %Note: ESD is a symmetric function of frequency
end
if (PartialSum_Xf2 >= pEXf)
break
end
end
Essential_BW_in_Hz = freq(k)
-----------------------------------------------------------
command Window
--------------------------------------------------------------
Enter desired percentage of Essential Bandwidth = 9
Essential_BW_in_Hz =
0.0977
------------------------------------------------------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.