0% found this document useful (0 votes)
66 views

Signal and Sys Assignment

This document contains the solutions to questions from a Signals and Systems course assignment. The questions cover topics like determining if signals are periodic, plotting even and odd components of a signal, obtaining the Fourier series expansion of a signal, and using MATLAB to calculate and plot the Fourier transform of rectangular and sinusoidal pulse functions. Code examples are provided to calculate the Fourier transform and plot the signals and their spectra. Key functions like fft and fftshift used in the Fourier transform calculation are explained.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Signal and Sys Assignment

This document contains the solutions to questions from a Signals and Systems course assignment. The questions cover topics like determining if signals are periodic, plotting even and odd components of a signal, obtaining the Fourier series expansion of a signal, and using MATLAB to calculate and plot the Fourier transform of rectangular and sinusoidal pulse functions. Code examples are provided to calculate the Fourier transform and plot the signals and their spectra. Key functions like fft and fftshift used in the Fourier transform calculation are explained.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

UNIVERSITI TEKNIKAL MALAYSIA MELAKA

FACULTY OF ELECTRONICS AND COMPUTER ENGINEERING

BENT 3733

COURSE : SIGNALS AND SYSTEMS

- Name: Ameen Mohammed Ameen AL Awadhi


Matric no: B022020061
- Name: Onovo Stanley Ejiofor
Matric no: B021920208
- Name: Abdelkarim Bassam Aboassi
Matric no: B022020059

COORDINATOR:

PROF. MADYA DR. MAISARAH ABU


QUESTION 1

(a) Determine if the following signals are periodic. If yes, determine the fundamental period.
(i) g1(t) = 3 sin(4πt) + 7 cos(3πt)
(ii) g2(t) = 3 sin(4πt) + 7 cos(10t)

answer
(I) g1(t) = 3 sin(4πt) + 7 cos(3πt)
is a periodic signal with a fundamental period of T = 1/(4π).
(II) g2(t) = 3 sin(4πt) + 7 cos(10t)
1
is not a periodic signal because the fundamental period of a cosine function is where f is the
f
frequency. In this case, the frequency of the cosine function is 10, so the fundamental period
1
would be , which is not a constant.
10
In MATLAB

t = 0:0.01:1;
g1 = 3*sin(4*pi*t) + 7*cos(3*pi*t);
g2 = 3*sin(4*pi*t) + 7*cos(10*t);

plot(t,g1)

The resulting plot for g1(t) will be a combination of a sine and cosine wave with a period of
1
T=
4(π)
and for g2(t) it will be a combination of a sine and non-periodic cosine wave.
(b) Figure 1 shows a signal of 𝑦(𝑡).
(i) Using MATLAB, write a script and the necessary functions to plot a signal.
(ii) Plot the even and odd components of the signal 𝑦(𝑡).
(iii)Verify analytically that the obtained figure is correct.

answer
(i) To plot a signal in MATLAB, script:

t = -5:0.01:5;
y = 5*sinc(t);
plot(t,y);
xlabel('t (sec)');
ylabel('y(t)');
(ii) To plot the even and odd components of the signal y(t), script:

y_even = (y + fliplr(y))/2;
y_odd = (y - fliplr(y))/2;

figure
subplot(2,1,1)
plot(t,y_even);
xlabel('t (sec)');
ylabel('y even(t)');

subplot(2,1,2)
plot(t,y_odd);
xlabel('t (sec)');
ylabel('y odd(t)');

The first plot will show the even component of the signal y(t) and the second plot will show
the odd component of the signal y(t).
(iii) To verify analytically that the obtained figure is correct, we can use the following
properties of even and odd functions:

➢ A function 𝑓(𝑡) is even if 𝑓(−𝑡) = 𝑓(𝑡) for all 𝑡


➢ A function 𝑓(𝑡) is odd if 𝑓(−𝑡) = −𝑓(𝑡) for all 𝑡

sin(πt)
The given signal y(t) is sin c function, y(t) = sinc(t) =
πt
which is an even function. Therefore, the even component of y(t) should be equal to y(t) and the
odd component of y(t) should be zero.
By comparing the plots obtained from the script with these properties, we can confirm that the
obtained figures are correct.
QUESTION 2
Consider Figure 2. Obtain the Fourier series expansion of m(t) in trigonometric and exponential
form. Then sketch its corresponding amplitude and phase spectrum. Verify your answer using
MATLAB.

answer
The Fourier series expansion of m(t) in trigonometric form is given by:

𝑎0
𝑚(𝑡) = + ∑ (𝑎𝑛 cos n 𝑤0 𝑡 + 𝑏𝑛 sin n 𝑤0 𝑡 )
2
𝑛=1
where 𝑎0 , 𝑎𝑛 and 𝑏𝑛 are the Fourier coefficients given by:
1 3𝜋
𝑎0 = 2π* ∫−2𝜋 𝑚(𝑡) 𝑑𝑡
1 3𝜋
𝑎𝑛 = * ∫−2𝜋 𝑚(𝑡 ) * cos 𝑛𝑤0 𝑡 𝑑𝑡
π
1 3𝜋
𝑏𝑛 = * ∫−2𝜋 𝑚(𝑡 ) * sin 𝑛𝑤0 𝑡 𝑑𝑡
π
2𝜋
where T = 2π is the period of m(t), 𝑤0 = is the fundamental frequency.
T
The Fourier series expansion of m(t) in exponential form is given by:
𝑎 ∞ 𝑐𝑛
m(t) = 20 + ∫𝑛=−∞ 𝑒 𝑗𝑛𝑤0 𝑡 𝑚(𝑡 )

where 𝑐𝑛 is the Fourier coefficient given by:


1 3𝜋
𝑐𝑛 = 2π * ∫−2𝜋 𝑚(𝑡) * 𝑒 𝑗𝑛𝑤0 𝑡 𝑑𝑡
Unfortunately, it is not possible to obtain the exact form of the Fourier series
expansion or sketch the amplitude and phase spectrum because the exact form of the function is not
provided. However, we can know that the Fourier series expansion will be a sum of sine and cosine
functions. The amplitude spectrum will be a plot of the magnitude of the Fourier coefficients, 𝑐𝑛 or
𝑎𝑛 , and the phase spectrum will be a plot of the phase of the Fourier coefficients, angle 𝑐𝑛 or angle 𝑎𝑛

Using the following code in MATLAB to plot the signal m(t) and the Fourier series
representation of m(t) with the first N harmonics:

t = -2*pi:0.01:3*pi;
y = zeros(size(t));
y(t>=-pi & t<0) = pi;
N = 5;

y_fourier = zeros(size(t));
for n=1:N
a_n = (2/pi)*trapz(t(t>=-pi &
t<0),y(t>=-pi & t<0).*cos(n*t(t>=-pi
& t<0)));
b_n = (2/pi)*trapz(t(t>=-pi &
t<0),y(t>=-pi & t<0).*sin(n*t(t>=-pi &
t<0)));
y_fourier = y_fourier + a_n*
QUESTION 3
Task 1: Fourier Transform of a Rectangular Pulse Function
Use the MATLAB program as given to find the Fourier transform, V(ω) for the rectangular pulse
as shown in Figure 3. Run the given code and explain the purpose of function “fft and fftshift.
% FOURIER TRANSFORM OF A RECTANGULAR PULSE

answer
fs=100; This MATLAB code calculates the Fourier Transform
of a rectangular pulse function and plots the resulting
ts=1/fs; spectrum.
t=-5:ts:5; The code first sets the sampling frequency (fs) to
v=rectpuls(t); 100 Hz and the time step (ts) to 1/fs = 0.01 seconds.
subplot(2,1,1);plot(t,v);grid; Then, it defines the time vector, t, that ranges from -5
to 5 seconds with a step of ts. The next line defines the
title('Rectangular Function'); rectangular pulse function, v, using the built-in
xlabel('Time function "rectpuls" in MATLAB, which generates a
(t)');ylabel('Amplitude (v(t))'); rectangular pulse with a width of 1, centered at t=0.
f=fs/1001*(-500:500); % The code then plots the rectangular pulse function
frequency resolution in the first subplot using the "plot" function and labels
V=ts*fft(v); % function to call the axes.
Fourier Transform Next, the frequency resolution is defined by the line
subplot(2,1,2);plot(f,fftshift(real "f=fs/1001*(-500:500)". The FFT of the rectangular
(abs(V))));grid; pulse is calculated by the line "V=ts*fft(v)", where the
function "fft" is used to calculate the FFT of the signal
xlabel('Frequency (Hz)'); v. The function "fftshift" is used to shift the
ylabel ('Fourier Transform zero-frequency component to the center of the
(V(f))'); spectrum so that it's easier to interpret the results.
axis([-10 10 0 1]);
The FFT of the rectangular pulse is then plotted in
the second subplot using the "plot" function, where the
magnitude of the complex number is plotted using the function "real(abs(V))" and the x-axis is
labeled as frequency in Hz and y-axis as Fourier Transform.
Finally, the "axis" function is used to set the limits of the x-axis to -10 and 10, and the y-axis to
0 and 1, so the plot can be clearly viewed.
In summary, the code calculates the Fourier Transform of a rectangular pulse function using the
built-in Matlab function "fft" and the function "fftshift" is used to shift the zero-frequency
component to the center of the spectrum so that it's easier to interpret the results. The resulting
spectrum is then plotted with frequency on the x-axis and the magnitude of the Fourier Transform
on the y-axis.
Task 2: Fourier Transform of a Sinusoid Pulse Function
Given a signal x(t) of sinusoid signal as below:

Based on MATLAB code example in task 1, rewrite the code and plot the signal both in time
and frequency domain.
Answer
rewrite the code in task 1 to calculate the Fourier Transform of a sinusoid pulse function:
In this code, the sampling
fs = 10000; % sampling frequency
frequency is set to 10000 Hz and
ts = 1/fs; % time step the time step is set to 1/fs = 0.0001
t = -0.5:ts:0.5; % time vector seconds. The time vector ranges
x = cos(2*pi*1000*t); % sinusoid pulse function from -0.5 to 0.5 seconds with a
x(t<-0.5 | t>0.5) = 0; % set x(t) = 0 for t < -0.5 or t > 0.5 step of ts. The sinusoid pulse
function is defined as x(t) =
cos(2pi1000*t) and set to 0 for t <
% plot the signal in time domain
-0.5 or t > 0.5
subplot(2,1,1);
. The signal is plotted in time
plot(t,x);
domain in the first subplot using
grid; the "plot" function, and the axes
title('Sinusoid Pulse Function'); are labeled. Then the FFT is
xlabel('Time (t)'); calculated by the line "X =
ylabel('Amplitude (x(t))'); ts*fft(x)", where the function "fft"
is used to calculate the FFT of the
signal x. The function "fftshift" is
% calculate the FFT and plot the signal in frequency domain
used to shift the zero-frequency
f = fs/1001*(-500:500); % frequency resolution component to the center of the
X = ts*fft(x); % function to call Fourier Transform spectrum so that it's easier to
subplot(2,1,2); interpret the results.
plot(f,fftshift(real(abs(X))));
grid; The FFT of the sinusoid pulse
xlabel('Frequency (Hz)'); is then plotted in the second
ylabel ('Fourier Transform (X(f))'); subplot using the "plot" function,
axis([-2000 2000 0 1]);
where the magnitude of the
complex number is plotted using
the function "real(abs(X))" and the
x-axis is labeled as frequency in
Hz and y-axis as Fourier Transform. The "axis" function is used to set the limits of the x-axis to
-2000 and 2000, and the y-axis to 0 and 1, so the plot can be clearly viewed.

In summary, the code calculates the Fourier Transform of a sinusoid pulse function using the
built-in MATLAB function "fft" and the function "fftshift" is used to shift the zero-frequency
component to the center of the spectrum so that it's easier to interpret the results. The resulting
spectrum is then plotted with frequency on the x-axis and the magnitude of the Fourier Transform
on the y-axis.
Task 3: Fourier Transform of a Mix Sinusoid Pulse Function
Given mix of sinusoid signal x(t) below:

(a) Write a MATLAB code and plot the time and frequency domain of the signal.
(b) What is the advantage of analyzing signal in frequency in this section
Answer
(a) Here is an example of a MATLAB code that calculates the Fourier Transform of the mix of
sinusoid pulse function and plots the signal in both time and frequency domains:

fs = 10000; % sampling frequency In this code, the


ts = 1/fs; % time step sampling frequency is
t = -0.5:ts:0.5; % time vector set to 10000 Hz and the
x = cos(2*pi*10*t) + 0.5*cos(2*pi*40*t); % mix of sinusoid pulse function
time step is set to 1/fs =
0.0001 seconds. The
x(t<-0.5 | t>0.5) = 0; % set x(t) = 0 for t < -0.5 or t > 0.5
time vector ranges from
-0.5 to 0.5 seconds with
% plot the signal in time domain a step of ts. The mix of
subplot(2,1,1); sinusoid pulse function
plot(t,x); is defined as x(t) =
cos(2pi10t) +
grid;
0.5cos(2pi40*t) and set
title('Mix of Sinusoid Pulse Function');
to 0 for t < -0.5 or t >
xlabel('Time (t)'); 0.5.
ylabel('Amplitude (x(t))');

The signal is plotted in


% calculate the FFT and plot the signal in frequency domain
time domain in the first
f = fs/1001*(-500:500); % frequency resolution subplot using the "plot"
X = ts*fft(x); % function to call Fourier Transform function, and the axes
subplot(2,1,2); are labeled. Then the
plot(f,fftshift(real(abs(X)))); FFT is calculated by the
line "X = ts*fft(x)",
grid;
where the function "fft"
xlabel('Frequency (Hz)');
is used to calculate the
ylabel ('Fourier Transform (X(f))'); FFT of the signal x. The
axis([-2000 2000 0 1]); function "fftshift" is
used to shift the zero-
frequency component to the center of the spectrum so that it's easier to interpret the results.
The FFT of the mix of sinusoid pulse is then plotted in the second subplot using the "plot"
function, where the magnitude of the complex number is plotted using the function "real(abs(X))"
and the x-axis is labeled as frequency in Hz and y-axis as Fourier Transform. The "axis" function
is used to set the limits of the x-axis to -2000 and 2000, and the y-axis to 0 and 1, so the plot can
be clearly viewed.

(b) The advantage of analyzing a signal in the frequency domain is that it allows you to see the
different frequency components that make up the signal. In this case, the signal is made up of two
sinusoids with frequencies of 10 Hz and 40 Hz. By analyzing the signal in the frequency domain,
you can see the relative amplitudes of these two frequencies and how they contribute to the overall
signal. Additionally, it allows you to identify any unwanted frequency components that may be
present in the signal and take appropriate actions to remove them.

QUESTION 4
(a) Using MATLAB, generate the Laplace transform for the following signals:

Answer
the Laplace transform of the given signals using MATLAB:
(i) Laplace transform of (t^3 + t^2 + 4t + 3) u(t):

syms t s
x = (t^3 + t^2 + 4*t + 3)*heaviside(t);
X = laplace(x);
disp(X);

(ii) Laplace transform of 2e^(-5t) sin(5t) u(t):

syms t s
x = 2*exp(-5*t)*sin(5*t)*heaviside(t);
X = laplace(x);
disp(X);
(iii) Laplace transform of 5cos(3t)u(t):

syms t s
x = 5*cos(3*t)*heaviside(t);
X = laplace(x);
disp(X);

(iv) Laplace transform of 8t^7 *e^(-5t)u(t):

syms t s
x = 8*t^7*exp(-5*t)*heaviside(t);
X = laplace(x);
disp(X);

In each of these examples, the "laplace" function is used to calculate the Laplace transform
of the given signals. The Heaviside function u(t) is used to define the time domain of each signal.
The function "disp" is used to display the Laplace transforms of the signals, which are represented
by the variable "X".
(c)
(iii) Using MATLAB, find 𝑣𝑜(𝑡) if we have 𝑣𝑖 (𝑡) = 𝑒 ^−2𝑡 𝑢(𝑡)V
Answer
To find the output voltage vo(t) if the input voltage vi(t) is given by vi(t) = e^(-2t)u(t)V, we
can use the circuit's transfer function H(s) and the input voltage's Laplace transform Vi(s) to
calculate the output voltage's Laplace transform Vo(s) and then use the inverse Laplace transform
to find the output voltage vo(t) in the time domain.

Here is an example of how to do this using MATLAB:

syms t s
This code first defines the
% Define the circuit's transfer function circuit's transfer function
H(s) = 4s / (s^2 + 4s + 20).
H = 4*s / (s^2 + 4*s + 20);
Then it defines the input
voltage vi(t) = e^(-2t)u(t)
% Define the input voltage function and find its Laplace transform and finds its Laplace
vi = exp(-2*t)*heaviside(t); transform Vi(s) using the
Vi = laplace(vi); "laplace" function. Then it
uses the circuit's transfer
function and the input
% Use the circuit's transfer function to find the output voltage's
Laplace transform voltage's Laplace transform
to find the output voltage's
Vo = H*Vi;
Laplace transform Vo(s)
using the symbolic
% Use the inverse Laplace transform to find the output voltage in the multiplication. Finally, it
time domain uses the
vo = ilaplace(Vo);

% Simplify the output voltage function


vo = simplify(vo);
disp(vo);

You might also like