Sarvajanik College of Engineering and Technology
B.E. II Electrical-Semester IV
Academic Year 2020-21
Name: UTKARSH Gandhi
Enrolment Number: 190420109013
Subject: Signal and System
Subject Code: 3150912
Lab Prof.: Dimple Bhanabhagvanwala
Urvi Jariwala
Sarvajanik Education Society
Sarvajanik College of Engineering & Technology
Dr. R. K. Desai Marg, Athwalines, Surat-395001 (Gujarat), India
Certificate
This is to certify that Mr. Utkarsh Gandhi of class BE 3,
semester 5, Branch ELECTRICAL Roll no. 13. Enrollment
number 190420109013 has satisfactorily completed his
laboratory coursework in Signal and System for the odd
semester ending in year 2021.
Date:
UTKARSH GANDHI - 190420109013
PRACTICAL-1 Date:14/06/2021
AIM: Write Description of deffrent MATLAB command.
Command Purpose
clc Clears command window.
clear Removes variables from memory.
exist Checks for existence of file or variable.
global Declares variables to be global.
help Searches for a help topic.
lookfor Searches help entries for a keyword.
quit Stops MATLAB.
who Lists current variables.
whos Lists current variables (long display).
cd Changes current directory.
UTKARSH GANDHI - 190420109013
date Displays current date.
delete Deletes a file.
diary Switches on/off diary file recording.
dir Lists all files in current directory.
load Loads workspace variables from a file.
path Displays search path.
pwd Displays current directory.
save Saves workspace variables in a file.
type Displays contents of a file.
what Lists all MATLAB files in the current directory.
wklread Reads .wk1 spreadsheet file.
disp Displays contents of an array or string.
fscanf Read formatted data from a file.
format Controls screen-display format.
fprintf Performs formatted writes to screen or file.
UTKARSH GANDHI - 190420109013
input Displays prompts and waits for input.
; Suppresses screen printing.
+, -, *, / Matrix math opration
.*, ./ Array multiplication and division
^, .^ Matrix and array power
\ Left devision
.’, ‘ Normal and complex conjugate transpose
==, ~= , <, >, <=, >= Relational operators
&&, ||, ~, Xor Logical operations (AND,
NOT, OR, XOR)
… Connect lines
% Description comment
‘Hello’ Definition of character vector.
“this is a string” Definition of a string
Str1 + str2 Append strings
UTKARSH GANDHI - 190420109013
Real(z) Real part of complex number
Imag(z) Imaginary part of complex number
angle (z) Phase angle in radias
Conj(z) Element wise complex conjugate
isreal(z) Determine whether array is real
Write syntax of different MATLAB Command.
Command Syntax
if expression
if, elseif, else
statements elseif
expressionstatements
else
statements
end
switch switch_expression
switch, case, otherwise
case case_expression
statements
case case_expression
statements
...
otherwise
UTKARSH GANDHI - 190420109013
statements
end
for index = values
for
statements
end
while expression
while
statements
end
try
try, catch
statements catch
exception
statements
end
break
break
return
return
continue
continue
end
end
clc
clc
UTKARSH GANDHI - 190420109013
fprintf(fileID,formatSpec,A1,...,An)
fprintf fprintf(formatSpec,A1,...,An)
nbytes = fprintf( )
L = length(X)
length
sz = size(A) szdim =
size size(A,dim)
szdim = size(A,dim1,dim2,…,dimN)
[sz1,...,szN] = size( )
S = sum(A)
sum S = sum(A,'all') S =
sum(A,dim) S =
sum(A,vecdim)
S = sum( ,outtype) S =
sum( ,nanflag)
C=A+B
plus, + C = plus(A,B)
Y = diff(X)Y =
diff diff(X,n)
Y = diff(X,n,dim)
C = A*B
mtimes, * C = mtimes(A,B)
b = mod(a,m)
mod
UTKARSH GANDHI - 190420109013
r = rem(a,b)
rem
Y = round(X)Y =
round round(X,N)
Y = round(X,N,type)
Y = round(t)
Y = round(t,unit)
Y = floor(X)Y =
floor
floor(t)
Y = floor(t,unit)
Y = fix(X)
fix
Y = ceil(X)Y =
ceil
ceil(t)
Y = ceil(t,unit)
A == B
eq, == eq(A,B)
tf = isequaln(A,B)
isequaln tf = isequaln(A1,A2,...,An)
tf = isequal(A,B)
isequal tf = isequal(A1,A2,...,An)
UTKARSH GANDHI - 190420109013
A ~= B
ne, ~= ne(A,B)
A<B
lt, < lt(A,B)
A <= B
le, <= le(A,B)
A>B
gt, > gt(A,B)
A >= B
ge, >= ge(A,B)
true
true T = true(n)T =
true(sz)
T = true(sz1,...,szN)
T = true( ,'like',p)
L = logical(A)
logical
tf = islogical(A)
islogical
k = find(X)k =
find find(X,n)
k = find(X,n,direction)
UTKARSH GANDHI - 190420109013
[row,col] = find( )
[row,col,v] = find( )
false
false F = false(n)F =
false(sz)
F = false(sz1,...,szN)
F = false( ,'like',p)
B = any(A)
any B = any(A,'all') B =
any(A,dim) B =
any(A,vecdim)
B = all(A)
all B = all(A,'all') B =
all(A,dim) B =
all(A,vecdim)
C = xor(A,B)
xor
A|B
or, | or(A,B)
~A
not, ~ not(A)
A&B
and, & and(A,B)
expr1 && expr2
Logical Operators: Short- expr1 || expr2
Circuit && ||
PRACTICAL – 2
AIM – GENERATION OF CT SIGNALS USING MATLAB
MATLAB CODE: -
OUTPUT: -
CONCLUSION: - Hence, we have generate the CT signals using
.m file in MATLAB and study their output waveforms.
PRACTICAL – 3
AIM – GENERATION OF DT SIGNALS USING MATLAB.
MATLAB CODE: -
CONCLUSION: - Hence, we have generate the DT signals
using .m file in MATLAB and study their output waveforms.
PRACTICAL – 4
AIM - IMPLEMENTATION OF Z-TRANSFORM USING MATLAB
A. - Z TRANSFORM
B. - POLE ZERO DIAGRAM
MATLAB CODE –
CONCLUSION: - We successfully create program that can give
Z transform of function and shows us poles and zeros
diagram.
PRACTICAL - 5
AIM: PERFORMING VARIOUS OPRATION ON SIGNALS
1) ADDITION
2) SUBTRACTION
3) MULTIPLICATION
4) DIVISION
MATLAB CODE:
CONCLUSION: -
We successfully Performing various operation on signals
1)Addition
2)Subtraction
3)Multiplication
4)Division
UTKARSH GANDHI - 190420109013
PRACTICAL – 6 Date: 19/07/2021
AIM: Performing various operation on signals (Part- II)
a) Amplitude scaling
b) Time Reversal
MATLAB CODE:
a) Amplitude scaling
clc;
clear all;
close all;
A = input('Enter Amplitude scaling factor = ');
x = [-1 2 1 0 1 -1];
nx = -3:1:2;
%for amplification opration
y1 = x*A;
ny1 = nx;
%for attenuation operation
y2 = x/A;
ny2 = nx;
%x and %y scale for display
n_min = [min(nx) min(ny1) min(ny2)];
XMIN = min(n_min)-0.5;
n_max = [max(nx) max(ny1) max(ny2)];
XMAX = max(n_max)+0.5;
y_min = [min(x) min(y1) min(y2)];
YMIN = min(y_min)-0.5;
y_max = [max(x) max(y1) max(y2)];
YMAX = max(y_max)+0.5;
%plot x
subplot(3,1,1);
stem(nx,x);
title('original signal');
AXIS([XMIN XMAX YMIN YMAX])
xlabel('samples');
ylabel('Amplitude');
grid on;
UTKARSH GANDHI - 190420109013
b)Time Reversal
clc;
close all;
clear all;
%Time reversal
x = [4 3 2 1]
nx = 0:1:3;
y = x;
ny = -nx;
XMIN = min(min(nx),min(ny));
XMAX = max(max(nx),max(ny));
YMIN = min(min(x),min(y));
YMAX = max(max(x),max(y));
%plot X
subplot(2,1,1);
stem(nx,x);
title('Original Signal');
AXIS([XMIN XMAX YMIN YMAX])
xlabel('Samples');
%ylabel('');
grid;
%plot Y
subplot(2,1,2);
stem(ny,y);
title('Inverted Signal');
AXIS([XMIN XMAX YMIN YMAX])
xlabel('Samples');
%ylabel('');
grid;
UTKARSH GANDHI - 190420109013
RESULT: -
a) Amplitude scaling
b) Time Reversal
UTKARSH GANDHI - 190420109013
Conclusion: - We successfully achieved various operation on signals
a) Amplitude scaling
b) Time Reversal
UTKARSH GANDHI - 190420109013
PRACTICAL-7 Date: 16/08/2021
AIM: Performing various operation on signals (Part - III)
• Time Shifting
• Time Scaling
MATLAB CODE:
Time Shifting Code
clc;
close all;
clear all;
%Time shifting
%k = input('Enter Time Shifting factor');
k = 2;
x = [4 3 2 1];
nx = 0:1:3;
%Delayed x[n-k]
y1 = x;
ny1 = nx+k;
%Advanced x[n+k]
y2 = x;
ny2 = nx-k;
%X and Y scale for display
n_min = [min(nx) min(ny1) min(ny2)]
XMIN = min(n_min)-0.5;
n_max = [max(nx) max(ny1) max(ny2)]
XMAX = max(n_max)+0.5;
y_min = [min(x) min(y1) min(y2)]
YMIN = min(y_min)-0.5;
y_max = [max(x) max(y1) max(y2)]
YMAX = max(y_max)+0.5;
%plot X
subplot(3,1,1);
stem(nx,x);
title('Original Signal');
axis([XMIN XMAX YMIN YMAX])
UTKARSH GANDHI - 190420109013
%xlabel('Samples');
%ylabel('');
grid;
%plot Y1 delayed signal
subplot(3,1,2);
stem(ny1,y1);
title('Delayed Signal');
axis([XMIN XMAX YMIN YMAX])
%xlabel('Samples');
%ylabel('');
grid;
%plot Y2 Advanced Signal
subplot(3,1,3);
stem(ny2,y2);
title('Advanced Signal');
axis([XMIN XMAX YMIN YMAX])
%xlabel('Samples');
%ylabel('');
grid;
Time Scaling Code
clc;
close all;
clear all;
%Time scaling
k = 2;
x = [-3 1 2 -1 1];
nx = -2:1:2;
%Compressed x[nk]
y1 = x;
ny1 = nx/k;
%Expanded x[n/k]
y2 = x;
ny2 = nx*k;
%X and Y scale for display
n_min = [min(nx) min(ny1) min(ny2)]
XMIN = min(n_min)-0.5;
n_max = [max(nx) max(ny1) max(ny2)]
XMAX = max(n_max)+0.5;
UTKARSH GANDHI - 190420109013
y_min = [min(x) min(y1) min(y2)]
YMIN = min(y_min)-0.5;
y_max = [max(x) max(y1) max(y2)]
YMAX = max(y_max)+0.5;
%plot X
subplot(3,1,1);
stem(nx,x);
title('Original Signal');
axis([XMIN XMAX YMIN YMAX])
%xlabel('Samples');
%ylabel('');
grid;
%plot Y1 delayed signal
subplot(3,1,2);
stem(ny1,y1);
title('Compresses Signal');
axis([XMIN XMAX YMIN YMAX])
%xlabel('Samples');
%ylabel('');
grid;
RESULTS: -
• Time Shifting
• Time Scaling
UTKARSH GANDHI - 190420109013
UTKARSH GANDHI - 190420109013
Conclusion: We successfully achieved various operation on signals
a) Time Shifting
b) Time Scaling
UTKARSH GANDHI - 190420109013
PRACTICAL-8 Date: 06/09/2021
AIM: Implementation of Z-transform using MATLAB (Part - II)
a) By iztrans
b) Partial Fraction Expansion method
c) Power Series Expansion
MATLAB CODE:
a) By iztrans
clc;
clear all;
close all;
syms z n;
X1=z/(z-2);
x1=iztrans(X1,z,n);
pretty (X1);
pretty (x1);
syms z n;
X2=2*z/(z- 2)^2;
x2=iztrans(X2,z,n);
pretty (X2);
pretty (x2);
syms z n;
X3=(6+9*z.^-1)/(1-2.5*z.^-1+z.^-2);
x3=iztrans(X3,z,n);
pretty (X3);
pretty (x3);
b) By Pratial expansion Method
% Partial Fraction
n1=[0 1/6]
d1=[1 -5/6 1/6]
B=tf(n1,d1)
UTKARSH GANDHI - 190420109013
[r1,p1,k1]=residuez(n1,d1)
%improper case
n2=[1 2 1]
d2=[1 -1 0.3561]
C=tf(n2,d2)
[r2,p2,k2]=residuez(n2,d2)
c) By Power Series Expansion
%long division
%Causal System
n = input('Enter the no of iterations: ');
%X[z] = 1/(1 - 1.5*Z^(-1) + 0.5*Z^(-2));
num1=[1 0 0]
den1=[1 -1.5 0.5]
num1_new=[num1 zeros(1,(n-1))]
[q1,r1]=deconv(num1_new,den1)
%Non causal System
%Y[Z] = (Z^2 + 2*Z)/(Z^3 - 3*Z^2 + 4*Z + 1)
n = input('Enter the no of iterations: ');
num2=[1 2 0]
den2=[1 -3 4 1]
num2_new=[num2 zeros(1,(n-1))]
[q2,r2]=deconv(num2_new,den2)
UTKARSH GANDHI - 190420109013
RESULT:
a) By iztrans
b) Partial Fraction Expansion method
UTKARSH GANDHI - 190420109013
c) Power series Expansion
UTKARSH GANDHI - 190420109013
Enter the no of iterations: 3
num1 =
1 0 0
den1 =
1.0000 -1.5000 0.5000
num1_new =
1 0 0 0 0
q1 =
1.0000 1.5000 1.7500
r1 =
0 0 0 1.8750 -0.8750
Enter the no of iterations: 3
num2 =
1 2 0
den2 =
1 -3 4 1
num2_new =
1 2 0 0 0
q2 =
1 5
r2 =
0 0 11 -21 -5
>>
UTKARSH GANDHI - 190420109013
CONCLUSION: We successfully Implementation of Z-transform using
MATLAB
a) By iztrans
b) Partial Fraction Expasion method
c) Power series Expansion
UTKARSH GANDHI - 190420109013
PRACTICAL - 9 Date: 13/09/2021
AIM: Perform Convolution of Given DT Signal using MATLAB.
MATLAB CODE:
%Convolution of two sequences x(n) and h9n)
%y(n) = x(n)*h(n)
clc;
clear all;
close all;
%X = [1 1 1];
X = input('Enter sequence X = ');
%nXl = 0;
nXl = input('Enter the starting sample no = ');
nXh = nXl+length(X)-1;
%H = [2 2];
H = input('Enter sequence H = ');
%nHl = 0;
nHl = input('Enter the starting sample no = ');
nHh = nHl+length(H)-1;
Y = conv(X,H);
disp(Y);
nYl = nXl+nHl;
nYh = nXh+nHh;
ny = nYl:nYh;
stem(ny,Y);
RESULT: -
UTKARSH GANDHI - 190420109013
Conclusion: We Perform Convolution of Given DT Signal using MATLAB