Signal N Systems Lab
Signal N Systems Lab
Lab Manual
Working environment: -
COMMANDS: -
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).
Command Purpose
disp Displays contents of an array or string.
fscanf Read formatted data from a file.
; Supress screen printing
fprintf Performs formatted writes to screen or file.
input Displays prompts and waits for input.
Array commands
Plotting commands
Command Purpose
axis Sets axis limits.
fplot Intelligent plotting of functions.
grid Displays gridlines.
plot Generates xy plot.
print Prints plot or saves plot to a file.
title Puts text at top of plot.
Xla`bel Adds text label to x-axis.
ylabel Adds text label to y-axis.
axes Creates axes objects.
close Closes the current plot.
close all Closes all plots.
figure Opens a new figure window.
gtext Enables label placement by mouse.
hold Freezes current plot.
legend Legend placement by mouse.
refresh Redraws current figure window.
Set Specifies properties of objects such as axes.
subplot Creates plots in subwindows.
text Places string in figure.
Bar Creates bar chart.
loglog Creates log-log plot.
polar Creates polar plot.
semilogx Creates semilog plot. (logarithmic abscissa).
semilogy Creates semilog plot. (logarithmic ordinate).
Applications: -
Statistics and machine learning (ML)
This toolbox in MATLAB can be very handy for the programmers. Statistical methods
such as descriptive or inferential can be easily implemented.
Curve fitting
The curve fitting toolbox helps to analyse the pattern of occurrence of data. After a
particular trend which can be a curve or surface is obtained, its future trends can be
predicted.
Control systems
Systems nature can be obtained. Factors such as closed-loop, open-loop, its
controllability and observability, Bode plot, Nyquist plot, etc can be obtained.
Signal Processing
Signals and systems and digital signal processing are taught in various engineering
streams. But MATLAB provides the opportunity for proper visualization of this.
Deep learning
Its a subclass of machine learning which can be used for speech recognition, financial
fraud detection, medical image analysis.
Image processing
The most common application that we observe almost every day are bar code scanners,
selfie (face beauty, blurring the background, face detection), image enhancement, etc.
Conclusion: -
MATLAB helps you take your ideas beyond the desktop. You can run your analyses on larger data
sets, and scale up to clusters and clouds. MATLAB code can be integrated with other languages,
enabling you to deploy algorithms and applications within web, enterprise, and production systems.
Experiment-2
Aim: - To study the shifting, time reversal and scaling of a given continous time domain signal.
MATLAB Code:
clc;
close all;
% the limits of the time for the signal are defined here
delta_t = 0.01;
strtime = -5;
endtime = 5;
t = strtime:delta_t:endtime;
x = zeros(size(t));
% The plot of three transformation of the signal with the limits of axes
subplot(5,1,5);
tnew = -t/2 - 3/2 ;
plot(tnew,x)
axis([-6 6 -2 2]);
grid on
title('all combined')
xlabel('t')
ylabel('x(-2t - 3)')
Output:
Conclusion:
These operations are crucial for analyzing and manipulating signals in various fields such as
communications, control systems, and signal processing. Understanding how each operation affects
the signal can help in designing and interpreting signal transformations effectively.
Experiment-3
Aim: - To compute convolution both in continous and discrete domain.
MATLAB Code:
clc
clear all;
close all;
Conclusion: Convolution, both in continuous and discrete domains, is essential for determining
the output of linear time-invariant systems given an input signal and the system's impulse response.
Mastering this operation is crucial for effective signal analysis and system design in various
engineering applications.
Experiment-4
Aim: - To generate a periodic square wave from it’s Fourier series expansion
MATLAB Code:
clc;
clear all;
close all;
Output:
Conclusion: Generating a periodic square wave from its Fourier series expansion demonstrates
the power of Fourier analysis in representing complex periodic signals using a sum of sinusoidal
components. By computing the Fourier series, we can approximate the square wave with increasing
accuracy, highlighting the significance of harmonic components in signal synthesis and analysis in
various engineering and scientific applications.
Experiment-5
Aim: - To generate a periodic Triangular waveform from it’s Fourier series expansion
MATLAB Code:
clc
clear;
subplot(2,1,2);
stem(k,angle(a));
axis([min(k) max(k) 1.1*min(angle(a)) 1.1*max(angle(a))]);
grid on
title('Fourier Series Coefficients (Phase)')
xlabel('k')
ylabel('a(k)')
Output:
Conclusion: Successfully generated a periodic triangular waveform by utilizing its Fourier series
expansion, enabling us to represent the waveform as a sum of sinusoidal functions, thus
demonstrating the capability of Fourier analysis in waveform synthesis.
Experiment-6
Aim: - To compute the inverse Fourier Transform of a continuous signal defined in frequency
domain.
MATLAB Code:
%scale factor should be varied and observed
T1 = 1.0; % time duration of the pulse being 1
% This examples will have X(omega) as completely real but since there might
% be small values of imaginary part, we completely set them to zero
X_omega = real(X_omega);
Output:
Conclusion: After completing the experiment, we efficiently computed the inverse Fourier
Transform of the continuous signal defined in the frequency domain, effectively transforming it
back into the time domain representation, thereby demonstrating the versatility and power of
Fourier analysis in signal processing tasks.
Experiment-7
Aim: - To compute the Fourier Transform of a continuous non-periodic signal (rectangular pulse).
MATLAB Code:
subplot(1,2,1)
plot(omega,X_omega, 'k');
%axis([min(omega) max(omega) 1.1*min(X_omega) 1.1*max(X_omega)]);
grid on
title('Original Signal')
xlabel('\omega')
ylabel('x(\omega)')
% The x-axis is being changed in the plot to have tick points at different values of pi
%set(gca,'xtick',[-2*pi:pi:2*pi])
%set(gca,'xticklabels',{'2\pi','\pi','0','\pi','2\pi'})
subplot(1,2,2)
plot(t,x,'r');
%axis([min(t) max(t) 1.1*min(x) 1.1*max(x)]);
grid on
title('Inverse Fourier Transform')
xlabel('t')
ylabel('x(t)')
Output:
Conclusion: Upon completing the experiment, we accurately computed the Fourier Transform of
the continuous non-periodic signal, such as a rectangular pulse, revealing its frequency domain
representation and showcasing the fundamental principles of Fourier analysis in characterizing
signals with finite duration.
Experiment-8
MATLAB Code:
clc
clear
% %Signal 1
% %time duration for which signal is being generated
% n = -3.0*N1:1:3.0*N1;
% % generating the rectangular pulse x(t)
% x(n >= -N1) = 1.0;
% x(n > N1) = 0.0;
% Signal 2
% time duration for which signal is being generated
n = -3.0*N1:1:3.0*N1;
% generating the rectangular pulse x(t)
x(n >= -N1) = -1.0;
x(n >= 0) = 1.0;
x(n > N1) = 0.0;
% % Signal 3
% n = -3.0*N1:1:3.0*N1;
% x(n >= -N1) = n(n >= -N1);
% x(n > N1) = 0.0;
NumberofCycles = 5;
NumberOfSampesPerPi = 100;
omega = -NumberofCycles*pi : pi/NumberOfSampesPerPi : NumberofCycles*pi;
X_omega = zeros(size(omega));
for ind = 1:length(n)
X_omega = X_omega + x(ind)*exp(1i*omega*n(ind));
end
subplot(3,1,3);
plot(omega,angle(X_omega));
axis([min(omega) max(omega) -2*pi 2*pi]);
grid on
title('DTFT phase')
xlabel('$\omega$','interpreter','latex')
ylabel('X($\omega$)','interpreter','latex')
set(gca,'xtick',[-NumberofCycles*pi:pi:NumberofCycles*pi])
set(gca,'xticklabels',{'-5\pi','-4\pi','-3\pi','-2\pi','-\pi','0','\pi','2\pi','3\pi','4\pi','5\pi'})
set(gca,'ytick',[-2*pi:pi:2*pi])
set(gca,'yticklabels',{'-2\pi','-\pi','0','\pi','2\pi'})
Output:
Conclusion: Following the experiment's conclusion, we effectively computed the Discrete Time
Fourier Transform (DTFT) of the signal, providing insights into its frequency content and
emphasizing the significance of DTFT in analyzing discrete-time signals' spectral characteristics.
Experiment-9
MATLAB Code:
syms z;
expr = -2*z/(1+z^2)^2;
"The differentiation of" "-(2*z)/(z^2 + 1)^2" "is" (8*z^2)/(z^2 + 1)^3 - 2/(z^2 + 1)^2
"The partial fraction of" "(z^2 + 1)/(z^3 - 3*z + 2)" "is" 4/(9*(z - 1)) + 2/(3*(z - 1)^2) +
5/(9*(z + 2))
"The poles of" "4/(9*(z - 1)) + 2/(3*(z - 1)^2) + 5/(9*…" "is" "-2" "1"
"zeros of" "4/(9*(z - 1)) + 2/(3*(z - 1)^2) + 5/(9*…" "is" "-1i" "1i"
Aim: - To perform Z-transform and Laplace transform using symbolic computation in matlab
MATLAB Code:
syms n z;
% Define the symbolic expression
x = (1/2)^n * cos(4*n);
% Calculate the Z-transform
X = ztrans(x);
% Display the symbolic expression and its Z-transform
disp('Symbolic Expression:');
disp(x);
disp('Z-transform:');
disp(X);
% Calculate the inverse Z-transform
x_inverse = iztrans(X);
% Display the regenerated symbolic expression
disp('Regenerated Symbolic Expression by Inverse Z-transform:');
disp(x_inverse);
syms t s;
% Define the symbolic expression
x = exp(-2*t)*sin(3*t);
% Calculate the Laplace transform
X = laplace(x);
% Display the symbolic expression and its Laplace transform
disp('Symbolic Expression:');
disp(x);
disp('Laplace Transform:');
disp(X);
% Calculate the inverse Laplace transform
x_inverse = ilaplace(X);
% Display the regenerated symbolic expression
disp('Regenerated Symbolic Expression by Inverse Laplace Transform:');
disp(x_inverse);
Output:
Symbolic Expression:
(1/2)^n*cos(4*n)
Z-transform:
(2*z*(2*z - cos(4)))/(4*z^2 - 4*cos(4)*z + 1)
&
Symbolic Expression:
sin(3*t)*exp(-2*t)
Laplace Transform:
3/((s + 2)^2 + 9)