EECE 2316 Signals and Systems
MATLAB Assignment
Question 1(10 marks)
MATLAB's plot command provides a convenient way to visualize data, such as graphing
f(t) against the independent variable t.
Axis labels are added using the xlabel and ylabel commands, where the desired string
must be enclosed by single quotation marks. The result is
shown in Fig. 1.
Figure 1: f(t) = sin (2π 10t + π/6).
The title command is used to add a title above the current axis.
Plot the graph in Figure 1 using MATLAB. ( 10 Marks)
Question 2 ( 20 marks)
Use Matlab to compute the Laplace transform of the following functions
cos(3t), exp(2t)sin(t)
Then use Matlab to compute the inverse Laplace transform of the three results you just
found, see Example A.
Example A:
The following commands compute the Laplace transform of t^3*sin(2*t):
>> syms s t
>> Y=laplace(t^3*sin(2*t),t,s)
The result is: Y = 96/(s^2+4)^4*s^3-48/(s^2+4)^3*s.
You may make the answer look better by typing >> pretty(Y) .
To undo the Laplace transform, simply use the command:
>> y=ilaplace(Y,s,t)
The result is y =t^3*sin(2*t) which is the original function, as it should be.
Question 3 (20 marks)
Consider the continuous-time signal:
x(t) = sin(2πt) * u(t) - sin(4πt) * u(t)
where u(t) is the unit step function.
Tasks:
1. Plot x(t) for t from -1 to 3 seconds using MATLAB.
2. Find and plot the convolution of x(t) with itself using MATLAB.
3. Briefly describe the difference between the original and convolved signals.
Instructions:
- Use linspace to create a time vector.
- Use conv function for convolution and adjust the time axis accordingly.
- Comment your MATLAB code clearly.
Sample MATLAB Solution:
% Define time vector
t = linspace(-1, 3, 1000);
dt = t(2) - t(1); % Time step size
% Define unit step function
u = @(t) double(t >= 0);
% Define x(t)
x = sin(2*pi*t).*u(t) - sin(4*pi*t).*u(t);
% Plot x(t)
figure;
plot(t, x, 'LineWidth', 2);
xlabel('Time (s)');
ylabel('Amplitude');
title('Plot of x(t) = sin(2πt)u(t) - sin(4πt)u(t)');
grid on;
% Convolution of x(t) with itself
x_conv = conv(x, x) * dt;
% Create new time vector for convolution result
t_conv = linspace(2*t(1), 2*t(end), length(x_conv));
% Plot convolution result
figure;
plot(t_conv, x_conv, 'r', 'LineWidth', 2);
xlabel('Time (s)');
ylabel('Amplitude');
title('Convolution of x(t) with itself');
grid on;