Engineering - Electrical Engineering Signals and Systems Homework
roblems
3 years ago
15
week1_supplement.pdf
DT_periodicity.m
DT_signal_transformation.m
system_properties.m
CT_signal_transformation.m
- chapter1_problems.pdf
week1_supplement.pdf
EEE203 Week 1 Supplement Problems
1. A continuous-time signal 𝑥(𝑡) is shown below. Sketch the following signals:
a) 𝑥(𝑡)𝑢(1 − 𝑡) b) 𝑥(𝑡)[𝑢(𝑡) − 𝑢(𝑡 − 1)]
c) 𝑥(𝑡)𝛿(𝑡 − 3
2 )
2. A discrete-time signal 𝑥[𝑛] is shown below. Sketch the following signals:
a) 𝑥[𝑛]𝑢[1 − 𝑛]
b) 𝑥[𝑛]{𝑢[𝑛 + 2] − 𝑢[𝑛]}
c) 𝑥[𝑛]𝛿[𝑛 − 1]
DT_periodicity.m
% Periodic and Aperiodic Discrete-Time Sinusoids % Author: Chao Wang close all; clear all; %% DT Sinusoids % 1.26 (a) omega1 = 6*pi/7; n1 = 0:5*ceil(2*pi/omega1); % graph roughly five periods x1 = sin(omega1*n1+1); % the DT signal t1 = [0:0.001:5*ceil(2*pi/omega1)]; x1_c = sin(omega1*t1+1); % the correponding CT signal figure stem(n1, x1, 'k'); % use stem to plot DT signals xlabel('n'), ylabel('x'); title_string = sprintf('x = sin(6\\pi/7*n+1)'); title(title_string); hold on plot(t1, x1_c, '--c') % compare with the CT signal % 1.26 (b) omega2 = 1/8; n2 = 0:2*ceil(2*pi/omega2); % graph roughly 2 periods x2 = cos(omega2*n2-pi); % the DT signal t2 = [0:0.001:2*ceil(2*pi/omega2)]; x2_c = cos(omega2*t2-pi); % the correponding CT signal figure stem(n2, x2, 'k'); % use stem to plot DT signals xlabel('n'), ylabel('x'); title_string = sprintf('x = cos(n/8-\\pi)'); title(title_string); hold on plot(t2, x2_c, '--c') % compare withthe CT signal % In the figure window, you can check "Tools->Data Cursor" % Now you can use your cursor to click on the top circle on the stem % to display the data value for that point.
DT_signal_transformation.m
% Plot of Discrete-Time Signals % Signal transformation and interaction with unit step and unit impulse % Author: Chao Wang close all; clear all; %% 1.22 b) figure n = -8:8; x = [0, 0, 0, 0, -1, -1/2, 1/2, 1, 1, 1, 1, 1/2, 0, 0, 0, 0, 0]; subplot(5, 1, 1) stem(n, x) title('x[n]') axis([-8, 8, -2, 2]) % set x an y axis limit % Method 1: first time reversal, then shift x1 = fliplr(x); % flip left to right, time reversal subplot(5, 1, 2) stem(n, x1) title('x[-n]') axis([-8, 8, -2, 2]) x2 = [zeros(1,3) x1(1:end-3)]; % shift right by 3, fill zeros at the front subplot(5, 1, 3) stem(n, x2) title('x[-(n-3)]') axis([-8, 8, -2, 2]) % Method 2: first shift then time reversal x3 = [x(4:end) zeros(1,3)]; % shift left by 3, fill zeros at the end subplot(5, 1, 4) stem(n, x3) title('x[n+3]') axis([-8, 8, -2, 2]) x4 = fliplr(x3); % flip left to right, time reversal subplot(5, 1, 5) stem(n, x4) title('x[-n+3]') axis([-8, 8, -2, 2]) %% supplement 2 % define DT unit step function, return 1 when n >= 0, return 0 otherwise unit_step = @(x) x>=0; % define DT delta function, return 1 when n = 0, return 0 otherwise delta = @(x) x==0; figure n = -4:4; x = [0, 3, 2, 1, 0, 1, 2, 3, 0]; subplot(4, 2, 2) stem(n, x) title('x[n]') axis([-4, 4, 0, 3]) x1 = unit_step(n); subplot(4, 2, 1) stem(n, x1) title('u[n]') axis([-4, 4, 0, 3]) % a) x2 = unit_step(1-n); subplot(4, 2, 3) stem(n, x2) title('u[1-n]') axis([-4, 4, 0, 3]) x3 = x.*unit_step(1-n); subplot(4, 2, 4) stem(n, x3) title('x[n]u[1-n]') axis([-4, 4, 0, 3]) % b) x4 = unit_step(n+2)-unit_step(n); subplot(4, 2, 5) stem(n, x4) title('u[n+2]-u[n]') axis([-4, 4, 0, 3]) x5 = x.*(unit_step(n+2)-unit_step(n)); subplot(4, 2, 6) stem(n, x5) title('x[n](u[n+2]-u[n])') axis([-4, 4, 0, 3]) % c) x6 = delta(n-1); subplot(4, 2, 7) stem(n, x6) title('\delta[n-1]') axis([-4, 4, 0, 3]) x7 = x.*delta(n-1); subplot(4, 2, 8) stem(n, x7) title('x[n]\delta[n-1]') axis([-4, 4, 0, 3])
system_properties.m
% Test system properties of time invariance and linearity % Author: Chao Wang clear all; close all; % 1.28 c) system y[n] = n*x[n] %% test of time invariance % define input x, can be any data x = 20:-1:1; n = 1:20; % first shift x by n0 n0 = 3; x1 = [zeros(1, n0), x(1:length(x)-n0)]; % then go through the system y[n] = n*x[n] y1 = x1.*n; % first go through the system y[n] = n*x[n] y = x.*n; % then shift output by n0 y2 = [zeros(1, n0), y(1:length(y)-n0)]; % compare the two branches y1 and y2 subplot(3, 2, 1) stem(n, x) xlabel('n') ylabel('x[n]') subplot(3, 2, 2) stem(n, n) xlabel('n') ylabel('n') subplot(3, 2, 3) stem(n, x1) xlabel('n') s = sprintf('x[n-%d]', n0); ylabel(s) subplot(3, 2, 4) stem(n, y1) xlabel('n') s = sprintf('y1=n*x[n-%d]', n0); ylabel(s) subplot(3, 2, 5) stem(n, y) xlabel('n') ylabel('n*x[n]') subplot(3, 2, 6) stem(n, y2) xlabel('n') s = sprintf('y2=(n-%d)*x[n-%d]', n0, n0); ylabel(s) y1-y2 % this is nonzero, so system is time variant. %% test of linearity % define input x1 and x2, can be any data x1 = 20:-1:1; x2 = 1:20; % linear combination of inputs x3 = a*x1 + b*x2 a = 2; b = -1; x3 = a*x1 + b*x2; % go through the system y3 = n.*x3; % inputs go through the system individually y1 = n.*x1; y2 = n.*x2; % linear combination of outputs y = a*y1 + b*y2 y = a*y1 + b*y2; % compare the two branches y and y3 figure subplot(3, 2, 1) stem(n, x1) xlabel('n') ylabel('x1[n]') subplot(3, 2, 2) stem(n, x2) xlabel('n') ylabel('x2[n]') subplot(3, 2, 3) stem(n, x3) xlabel('n') ylabel('x3[n]=a*x1[n]+b*x2[n]'); subplot(3, 2, 4) stem(n, y3) xlabel('n') ylabel('y3[n]=n*x3[n]') subplot(3, 2, 5) stem(n, y1) hold on; stem(n, y2) xlabel('n') ylabel('y1[n] & y2[n]') subplot(3, 2, 6) stem(n, y) xlabel('n') ylabel('y[n]=a*y1[n]+b*y2[n]'); y-y3 % this is zero, so system is linear.
CT_signal_transformation.m
% Plot of Continuous-Time Signals % Signal transformation and interaction with unit step % Author: Chao Wang close all; clear all; syms t ; % define t to be symbolic (using the symbolic math toolbox) % Use subplot(m, n, p) function to reduce the number of figure windows % and for easy comparison. The figure window will be divided into m x n % matrix, p is the figure index, which counts up from left to right % starting from the 1st row, then 2nd row, etc. % You can always use "help command_name" in the command window to % display information on how to use a command such as % rectangularPulse and/or triangularPulse % 1.21 x=rectangularPulse(-1,0,t)+2*rectangularPulse(0,1,t)... -triangularPulse(-2,-2,-1,t)+triangularPulse(1,1,2,t); subplot(3, 1, 1) fplot(x) title('x(t)') axis([-5, 5, -2, 3]) % set x an y axis limit grid on % display grid lines grid minor % display minor grid lines for readability % 1.21(b) x1=rectangularPulse(-1,0,2-t)+2*rectangularPulse(0,1,2-t)... -triangularPulse(-2,-2,-1,2-t)+triangularPulse(1,1,2,2-t); subplot(3, 1, 2) fplot(x1) title('x(2-t)') axis([-5, 5, -2, 3]) grid on grid minor %1.21(d) x2=rectangularPulse(-1,0,4-t/2)+2*rectangularPulse(0,1,4-t/2)... -triangularPulse(-2,-2,-1,4-t/2)+triangularPulse(1,1,2,4-t/2); subplot(3, 1, 3) fplot(x2) title('x(4-t/2)') axis([3, 13, -2, 3]) grid on grid minor %% supplement 1 figure x=rectangularPulse(0,1,t)+2*rectangularPulse(1,2,t)... +triangularPulse(-1,0,0,t); subplot(3, 2, 2) fplot(x) title('x(t)') axis([-2, 3, -1, 3]) grid on grid minor x1=heaviside(t); subplot(3, 2, 1) fplot(x1) title('u(t)') axis([-2, 3, -1, 3]) grid on grid minor % a) x2=heaviside(1-t); subplot(3, 2, 3) fplot(x2) title('u(1-t)') axis([-2, 3, -1, 3]) grid on grid minor x3=x*heaviside(1-t); subplot(3, 2, 4) fplot(x3) title('x(t)u(1-t)') axis([-2, 3, -1, 3]) grid on grid minor % b) x4=heaviside(t)-heaviside(t-1); subplot(3, 2, 5) fplot(x4) title('u(t)-u(t-1)') axis([-2, 3, -1, 3]) grid on grid minor x5=x*(heaviside(t)-heaviside(t-1)); subplot(3, 2, 6) fplot(x5) title('x(t)[u(t)-u(t-1)]') axis([-2, 3, -1, 3]) grid on grid minor