In: Electrical Engineering
In this exercise, you will be given a system with their input/output relationships. Using MATLAB, determine whether the system below are a) linear/non-linear b) time-invariant/timevariant, c) causal/noncausal, d) has memory/memoryless:
y[n] = x2[n]
Provide MATLAB code and graphs to show your work for the linearity and time-invariance testing
MATLAB code is given below
clc;
close all;
clear all;
% Let the input be a ramp sequence
n = 0:1:50;
x = n; % Input is unit ramp sequence
figure;stem(n,x,'fill');grid on;
xlabel('n');ylabel('Stem Height');title('Input
Sequence');
% Linearity test question (a)
y = x.^2;
figure;stem(n,y,'fill');grid on;
xlabel('n');ylabel('Stem Height');title('Output
Sequence');
It is observed from the above figure that, the rseponse y[n] for unit ramp is parabolic. Hence input output relation is not proportional. Therefore the system is non-linear.
% Time invariance test question (b)
% A Time invariant system output does not depend on when the input
is
% applied
n_shift = 50:100; % Shift in time
figure;stem(n_shift,y,'fill');grid on;
xlabel('n');ylabel('Stem Height');title('Output Sequence when the
input is applied at n = 50');
It is observed from the above figure that, input at n = 50 has caused the output at n = 50. Therefore the systems outout does not depend on when the input is appled. Hence the system is Time-Invariant.
% Test on causality
% A system is causal when the its unit sample response is zero for
n<0
% the systems output when the input is unit sample is given
below
x = 1*(n == 0); % unit sample
h = x.^2; % unit sample response
figure;stem(n,h,'fill');grid on;
xlabel('n');ylabel('Stem Height');title('Unit sample
response');
It is observed from the above figure that, the system's output is zero for n<0 which indicates that system is causal.
% Question (d)
From the above figure it is observed that h[n] = 0 for n>0 which indicate that the system is memoryless system.