CL Experiments
CL Experiments
Part – A Module – 1
Introduction to MATLAB
1. Introduction
SIMULATE means “create a representation or model of/ to appear to be real,/an act
of / Something made to resemble something else. “
Simulation is the imitation of the operation of a real-world process or system over
time. The act of simulating something first requires that a model be developed; this model
represents the key characteristics or behaviors/functions of the selected physical or abstract
system or process. The model represents the system itself, whereas the simulation
represents the operation of the system over time.
Simulation is used in many contexts, such as simulation of technology for
performance optimization, safety engineering, testing, training, education, and video games.
Often, computer experiments are used to study simulation models. Simulation is also used
with scientific modeling of natural systems or human systems to gain insight into their
functioning. Simulation can be used to show the eventual real effects of alternative
conditions and courses of action. Simulation is also used when the real system cannot be
engaged, because it may not be accessible, or it may be dangerous or unacceptable to
engage, or it is being designed but not yet built, or it may simply not exist.
1.1 History & Overview of MATLAB:
MATLAB full form is “Matrix laboratory”
MATLAB (matrix laboratory) is a numerical computing environment and fourth-
generation programming language.
Invented in the year 1970 by Cleve Moler, and was modified by Jack little and Steve
bangert.
Mathworks was started in 1984.
MATLAB is originally designed to provide student’s access to LINPACK & EISPACK
without learning FORTRAN.
MATLAB is numerical computing environment and programming language, used for
applied mathematics.
MATLAB was first adopted by control design engineers and spread to many other
domains; it is particularly used in education field and Industry/Scientific/Military
applications.
MATLAB began with 80 functions, now it has over 8000 functions; MATLAB
engineers incorporated the LAPACK, BLAS libraries, embedding the state of the art
software for matrix computation.
MATLAB today has millions of users and a standard tool in both professional and
academic use.
MATLAB has inbuilt TOOLBOXES ( Control Systems, Communications, Neural
Networks, Image-processing, Signal Processing, Bioinformatics………………etc.,)
MATLAB has a GUI based simulation tool (SIMULINK).
MATLAB is a high performance language for technical computing, it integrates
computation, visualization and programming in an easy to use environment where
problems and solutions are expressed in familiar mathematical notation.
MATLAB is used in Math and Computation, Algorithm development, Data
acquisition, Modeling, “Simulation “, Prototyping, Data analysis exploration
visualization, Scientific and engineering graphics, Application development.
MATLAB is interactive system whose basic data element is an array that does not
require dimensioning. This allows solving many technical computing problems,
especially those with matrix and vector formulations, in a fraction of the time it
would take to write a program in a scalar non-interactive language such as C or
FORTRAN.
MATLAB system is technically called an interpreter, which means that each
statement presented to the command line is translated into language the computer
understand better and then immediately carried out.
MATLAB is case-sensitive, which means that a + B is not the same as a + b. The
MATLAB prompt (») in command window is where the commands are entered.
Matlab is capable to interpret and evaluate the numerical matrices expressions as
a) Directly from keyboard in command window
b) Or on form of sequences of expressions which are saved in a text file, called m-file
and execute it in command window.
c) Or more rarely on form binary file which is called mex-files or file of extension .mex
generated from a C compiler
1.2 Procedure to open MATLAB:
1. Open the MATLAB, by double clicking the icon on desktop.
2. Below window is launched with default layout.
c) Current directory/Workspace:
The Current directory window displayed the list of all the files and folders under the current
directory, which happens to be the ‘work’ sub-directory, by default, under the MATLAB root
directory. Since the ‘MATLAB’ directory will normally be in the hard disk C: / in your system,
where all the application software packages are stored, you should never use the default
directory for saving your MATLAB Files.
Workspace represents all the variables that are declared in Command Window.
VARIABLES: A variable is a name that is assigned to a value stored in the computer’s
memory. The variable names in MATLAB must begin with a letter, and they may be followed
by any combination of letters, digits, and underscores.
EXPRESSIONS AND STATEMENTS: An expression may consist of numbers, variable names and
some pre-defined functions such as sin, cos, log etc., arithmetic operators such as +,-,/ etc.,
relational operators such as <, > etc., and some special characters such as space, (
semicolon, ] etc., Evaluation of the expression produces a matrix.
MATLAB has 6 relational operators to make comparisons between variables. These are
< is less than
<= is less than or equal to
> is greater than
>= is greater than or equal to
== is equal to
~= is not equal to
Typical commands:
1. Whos
2. who
3. clear
4. quit
5. save filename – filename.mat
6. load filename - retrieve
7. dairy filename - b4 and after ASCII text file
8. help
1.3 Built in Functions:
1.3.1 Scalar Functions:
Certain MATLAB functions are essentially used on scalars, but operate element-wise when
applied to a matrix (or vector). They are summarized below.
1. sin - trigonometric sine
2. cos - trigonometric cosine
3. tan - trigonometric tangent
4. asin - trigonometric inverse sine (arcsine)
5. acos - trigonometric inverse cosine (arccosine)
6. atan - trigonometric inverse tangent (arctangent)
7. exp - exponential
8. log - natural logarithm
9. abs - absolute value
10. sqrt - square root
11. rem - remainder
12. round - round towards nearest integer
13. floor - round towards negative infinity
14. ceil - round towards positive infinity
Experiment No.
Objectives:
(A). To generate various signals such as Unit impulse, Unit step, Square, Saw tooth,
Triangular, Sinusoidal, Ramp, Sinc Function.
(B). To generate various sequences such as Unit impulse, Unit step, Square, Saw
tooth, Triangular, Sinusoidal, Ramp, Sinc Function.
Apparatus:
1. What does MATLAB stand for and which version of MATLAB did you use?
----------------------------------------------------------------------------------------------------------------
4. How many toolboxes does MATLAB provide approximately? Name some of them.
----------------------------------------------------------------------------------------------------------------
5. Distinguish between continuous time and discrete time signals.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
t=-20: 1:20
%--------------------Unit Impulse---------------------%
x=[zeros(1,20), 1,zeros(1,20)] %generate Unit Impulse Signal
figure(1), plot(t,x); % plot the generated Unit Impulse Signal
xlabel('t'); ylabel('x(t)'); title('Unit impulse Signal');
%------------------ Unit Step signal------------------%
y=[zeros(1,20), 1,ones(1,20)]
%y=[zeros(1,20),ones(20,1)] %generate Unit Step Signal
figure(2); plot(t,y); %Plot the generated unit step signal
xlabel('t'); ylabel('x(t)'); title('Unit Step Signal');
%---------------------- Ramp Signal------------------%
x1 = t;
x2 = 0;
x = x1.*(t>=0)+x2.*(t<0); %generate unit ramp signal
figure(3);plot(t,x); % plot the generated ramp signal
xlabel('t'); ylabel('x(t)'); title(' Ramp Signal');
%----------------------rectangular pulse------------%
t1=-10:0.01:10
a7=rectpuls(t1/10)
figure(4),plot(t1,a7), grid on,axis([-10 10 -2 2])
xlabel('time')
ylabel('magnitude')
title('rectangular pulse')
%-------------------- triangular pulse---------------%
t2=-10:0.1:10
a8=tripuls(t2)
figure(5),plot(t2,a8), grid on
title('triangular pulse')
xlabel('time')
ylabel('magnitude')
Expected Graphs:
(B) Program:
t=-20: 1:20
%--------------------Unit Impulse---------------------%
x=[zeros(1,20), 1,zeros(1,20)] %generate Unit Impulse Signal
figure(1), stem(t,x); % plot the generated Unit Impulse Signal
xlabel('t'); ylabel('x(t)'); title('Unit impulse Signal');
%------------------ Unit Step signal------------------%
y=[zeros(1,20), 1,ones(1,20)]
%y=[zeros(1,20),ones(20,1)] %generate Unit Step Signal
figure(2); stem(t,y); %Plot the generated unit step signal
xlabel('t'); ylabel('x(t)'); title('Unit Step Signal');
%---------------------- Ramp Signal------------------%
x1 = t;
x2 = 0;
x = x1.*(t>=0)+x2.*(t<0); %generate unit ramp signal
figure(3);stem(t,x); % plot the generated ramp signal
xlabel('t'); ylabel('x(t)'); title(' Ramp Signal');
%----------------------rectangular pulse------------%
t1=-10:0.1:10
a7=rectpuls(t1/10)
figure(4),stem(t1,a7), grid on,axis([-10 10 -2 2])
xlabel('time')
ylabel('magnitude')
title('rectangular pulse')
%-------------------- triangular pulse---------------%
t2=-10:0.1:10
a8=tripuls(t2)
figure(5),stem(t2,a8), grid on
title('triangular pulse')
xlabel('time')
ylabel('magnitude')
%--------------- Sinc Signal----------------------%
x = linspace(-5,5);
y = sinc(x);
figure(6);stem(x,y)
xlabel('time');
ylabel('amplitude');
title('sincfunction');
%-----------------Sinusoidal Signal----------------%
T = 20; %declare time period
F = 1/T; %compute frequency
x = sin(2*pi*F*t); %generate sinusoidal signal
figure(7);stem(t,x); % plot the generated sinusoidal signal
xlabel('t'); ylabel('x(t)'); title('sinusoidal Signal');
%---------------- Sawtooth signal-----------------%
fs = 1000;
t = 0:1/fs:1.5;
x = sawtooth(2*pi*50*t); %generate sawtooth signal
figure(8);stem(t,x); axis([0 0.2 -1 1]); %plot the generated sawtooth signal
xlabel('t'); ylabel('x(t)'); title('sawtooth Signal');
%----------------- square signal---------------------%
t=(0:0.01:10);
sq_wave=square(4*pi*t); %generate square signal
figure(9); stem(t,sq_wave); axis([0 5 -2 2]) %plot the generated square signal
xlabel('t'); ylabel('x(t)'); title('square signal');
%---------------------periodic triangle------------%
T=20;
x=linspace(0,5*T,1000);
y1=min(0.5,mod(x,T)/T);
y2=min(0.5,1-mod(x,T)/T);
figure(10),stem(x,y1+y2),grid on
xlabel('time')
ylabel('magnitude')
title('periodic triangle wave')
Expected Graphs:
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
2. Write a MATLAB code for generation of sinusoidal signal with frequency 50HZ.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
3. Write a MATLAB code for to generate a random signal.
----------------------------------------------------------------------------------------------------------------
4. Write a MATLAB code to plot a magnitude and phase of a complex exponential
signal.
----------------------------------------------------------------------------------------------------------------
5. Which MATLAB command divides the graphic space into six parts and select 5th part?
----------------------------------------------------------------------------------------------------------------
Outcomes:
1. Understood the ways of creating a MATLAB m-file, using the MATLAB Editor, run it
and view the results.
2. Understood the usefulness of different types of signals and sequences.
3. Write MATLAB code to generate any type of signals.
Grading:
Date of
Submission
Marks Awarded Pre-Lab Observations Calculations Post-Lab Viva Total*(10M)
(Max.Marks- Questions (2M) &Graph Questions (2M)
10M) (2M) (2M) (2M)
Remarks
Signature of the
Evaluator with
Date
Notes:
Experiment No.
Objectives:
Apparatus:
3. Draw the schematic of a time delay system that delays the signal x(n) by k samples.
----------------------------------------------------------------------------------------------------------------
4. What do you mean by scaling a signal? Where do you find the need for scaling
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
5. Which operation shifts the signal towards right?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
title('multiplication');
ylabel('Amplitude')
xlabel('Time (s)')
% Amplitude scaling
t = [0:.01:1]; % independent (time) variable
A = 8; % amplitude
f1 = 2; % create a 2 Hz sine wave lasting 1 sec
s1 = A*sin(2*pi*f1*t);
subplot(3,1,1)
plot(s1);
xlabel('t');
ylabel('amplitude');
title('input signal');
s2=2*s1;
subplot(3,1,2)
plot(s2);
xlabel('t');
ylabel('amplitude');
title('amplified input signal');
s3=s1/2;
subplot(3,1,3)
plot(s3);
xlabel('t');
ylabel('amplitude');
title('attenuated input signal');
% Time scaling
t = [0:.05:pi]; % independent (time) variable
A = 8; % amplitude
f1 = 2; % create a 2 Hz sine wave lasting 1 sec
s1 = A*sin(2*pi*f1*t);
subplot(3,1,1)
plot(s1);
xlabel('t');
ylabel('amplitude');
title ('sine signal')
s2=A*sin(2*2*pi*f1*t); % scaling by a=4
subplot(3,1,2)
plot(s2);
xlabel('t');
ylabel('amplitude');
plot(nx,x);
xlabel('nx');ylabel('amplitude)');
title('original signal');
subplot(2,1,2);
plot(nf,xf);
xlabel('nf');
ylabel('amplitude');
title('folded signal');
%-------------------computation of energy and power---------------%
x=10*sin(10*pi*t);To=10
xsq=x.^2;
E = trapz(t,xsq);
P = E/(2*To);
disp([' Energy, E = ', num2str(E),' Joules']);
disp([' Power, P = ', num2str(P),' Watts']);
Expected Graphs:
(B) Program:
ylabel('amplitude');
title ('sine signal')
s2=A*sin(2*2*pi*f1*t); % scaling by a=4
subplot(3,1,2)
stem(s2);
xlabel('t');
ylabel('amplitude');
title ('scaled sine signal with a=4')
s3=A*sin(.5*pi*f1*t); % scaling by a=1/4
subplot(3,1,3);
stem(s3);
xlabel('t');
ylabel('amplitude');
title ('scaled sine signal with a=1/4')
%--------------------time shifting---------------%
clc
clear all
close all
t = [0:.01:pi]; % independent (time) variable
A = 8; % amplitude
f1 = 2;
s1 = A*sin(2*pi*f1*t);
subplot(3,1,1)
stem(t,s1)
xlabel('t');
ylabel('amplitude');
title('input signal')
subplot(3,1,2)
stem(t+10,s1)
xlabel('t');
ylabel('amplitude');
title('right shifted signal')
subplot(3,1,3)
stem(t-10,s1)
xlabel('t');
ylabel('amplitude');
title('left shifted signal');
subplot(3,3,8);stem(E);
title('energy');
p=norm(E)^2/length(x4);
subplot(3,3,9);stem(p);
title('power');
Expected Graphs:
----------------------------------------------------------------------------------------------------------------
2. Write a MATLAB code o multiply the following two vectors. Check manually if the
result is as desired. A=[1 2 3 4 5] B=[4 6 1 7 8]
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
3. Write a MATLAB code for to generate a random signal.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
4. Which operation shifts the signal toward right?
----------------------------------------------------------------------------------------------------------------
5. When a signal is time advanced what type of a change occurs in it.
----------------------------------------------------------------------------------------------------------------
Outcomes:
Grading:
Date of
Submission
Marks Awarded Pre-Lab Observations Calculations Post-Lab Viva Total*(10M)
(Max.Marks- Questions (2M) &Graph Questions (2M)
10M) (2M) (2M) (2M)
Remarks
Signature of the
Evaluator with
Date
Notes:
Experiment No.
Objectives:
Apparatus:
3. Draw the block diagram representation of the input output relationship of an LTI
system.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
5. Which mathematical equation represents the convolution between two sequences?
----------------------------------------------------------------------------------------------------------------
(A ) Program:
Expected Graphs:
(B) Program:
clear all;
x=[1,2,1,2,1,3,2];
N1=length(x);
n=0:1:N1-1;
subplot(2,2,1),stem(n,x);
xlabel('n'),ylabel('x(n)');
title('input sequence x(n)');
h=[1,-1,2,-2,1,1];
N2=length(h);
n1=0:1:N2-1;
subplot(2,2,2),stem(n1,h);
xlabel('n');ylabel('h(n)');
title('impulse signal h(n)');
y=conv(x,h);
n2=0:1:N1+N2-2;
subplot(2,1,2),stem(n2,y);
xlabel('n'),ylabel('y(n)'); title('convolution of 2 sequences x(n) and h(n)');
Expected Graphs:
----------------------------------------------------------------------------------------------------------------
2. Which MATLAB command computes the convolution between two sequences a
and b?
----------------------------------------------------------------------------------------------------------------
4. When do you get h(n) at the output of an LTI system.
Outcomes:
Grading:
Date of
Submission
Marks Awarded Pre-Lab Observations Calculations Post-Lab Viva Total*(10M)
(Max.Marks- Questions (2M) &Graph Questions (2M)
10M) (2M) (2M) (2M)
Remarks
Signature of the
Evaluator with
Date
Notes:
Experiment No.
Autocorrelation & Cross Correlation
Objectives:
(A). To generate various signals such as Unit impulse, Unit step, Square, Saw tooth,
Triangular, Sinusoidal, Ramp, Sinc Function.
(B). To generate various sequences such as Unit impulse, Unit step, Square, Saw
tooth, Triangular, Sinusoidal, Ramp, Sinc Function.
Apparatus:
3. What are the steps involved in the computation of correlation? How do they differ
when compared with those of convolution?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
(A ) Program:
Expected Graphs:
(B) Program:
Expected Graphs:
1. How do you compute cross correlation between x and y using the ‘conv’ command?
2. Write MATLAB program to prove that the auto correlation between two discrete
time signals, without using the built-in ‘xcorr’ command.
3. Write MATLAB code for computing the cross correlation of two periodic sequences,
each of period N.
----------------------------------------------------------------------------------------------------------------
Outcomes:
Grading:
Date of
Submission
Marks Awarded Pre-Lab Observations Calculations Post-Lab Viva Total*(10M)
(Max.Marks- Questions (2M) &Graph (2M) Questions (2M)
10M) (2M) (2M)
Remarks
Signature of the
Evaluator with
Date
Notes:
Experiment No.
Objectives:
Apparatus:
3. What are advantages of LTI systems because of which they are very popular.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A )Program:
N=128;
f1=150;
f2=300;
fs=8000;
n=0:N-1;
x1=sin(2*pi*(f1/fs)*n);
x2=cos(2*pi*(f2/fs)*n);
y1=x1;
y2=x2;
figure(1);
subplot(3,3,1);
plot(n,x1);
grid;
title('signal x1(t)');
subplot(3,3,2);
plot(n,y1);
grid;
title('signal y1(t)');
subplot(3,3,3);
plot(n,x2);
grid;
title('signal x2(t)');
subplot(3,3,4);
plot(n,y2);
grid;
title('signal y2(t)');
%signal delay
x1d=[zeros(1,20),x1(1:N-20)];
subplot(3,3,5);
plot(n,x1d);
grid;
title('delayed x1d(n),[x1(n-20)]');
y1d=x1d;
subplot(3,3,6);
plot(n,y1d);
title('delayed y1d(n),[y1(n-20)]');
x2d=[zeros(1,20),x2(1:N-20)];
subplot(3,3,7);
plot(n,x2d);
grid;
title('delayed x2d(n),[x2(n-20)]');
y2d=x2d;
subplot(3,3,8);
plot(n,y2d);
grid;
title('delayed y2d(n),[y2(n-20)]');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x1=input('enter first input sequence');
x2=input('enter second input sequence');
y1=x1;y2=x2;
if[(x1+x2)==(y1+y2)]
disp('given sequence is additive');
else
disp('given sequence is non additive');
end
k=input('enter scaling value of k');
y3=k*x1;y4=k*x2;
if((k*x1+k*x2)==(k*y1+k*y2))
disp('given sequence is homegene');
else
disp('given sequence is not homegene');
end
%%%%%%%%
N1=length(x1);
n=0:1:N1-1;
subplot(3,3,1);stem(n,x1);
xlabel('n'),ylabel('x');
title('first input sequence x1[n]');
N2=length(x2);
m=0:1:N2-1;
subplot(3,3,2);stem(m,x2);
xlabel('m'),ylabel('x');
title('second input sequence x2[n]');
x1d=[zeros(1,2),x1(1:N1-2)];
subplot(3,3,3),stem(n,x1d);
xlabel('n-2'),ylabel('x1[n-2]');
title('delayed input sequence x1[n-2]');
N3=length(x1);
n1=0:1:N3-1;
subplot(3,3,4);stem(n1,y1);
xlabel('n1'),ylabel('y1');
title('first output sequence y1[n]');
y1d=[zeros(1,2),y1(1:N3-2)];
subplot(3,3,5),stem(n1,y1d);
xlabel('n-2'),ylabel('y1[n-2]');
N4=length(y2);
n2=0:1:N4-1;
subplot(3,3,6);stem(n2,y2);
xlabel('n2'),ylabel('y2');
title('second output sequence y2[n]');
y2d=[zeros(1,2),y1(1:N4-2)];
subplot(3,3,7),stem(n2,y2d);
xlabel('n-2'),ylabel('y2[n-2]');
title('second delayed input sequence y1[n-2]');
%%%%%%%%%%%%%%
subplot(3,3,8),stem(n1,y3);
xlabel('n1'),ylabel('y3');
title('output sequence y3=k*x1');
subplot(3,3,9),stem(n2,y4);
xlabel('n2'),ylabel('y4');
title('output sequence y4=k*x2');
%%%%%%%%%%%%%
if(x1d==y1d)
disp('given sequence is an linear time invarient system');
else
disp('given sequence is not a linear time invarient system');
end
Expected Graphs:
(B) Program:
t=-10:0.1:10;
y1=sin(t);
y2=cos(t);
subplot(121),plot(t,y1),title('sinewave');grid on
subplot(122),plot(t,y2),title('coswave');grid on
%--------------------linearity property---------------%
y3=2*y1;
y4=3*y2;
y5=y3+y4;
y6=t.*y5;
y7=t.*y3;
y8=t.*y4;
y9=y7+y8;
e=(y6)-(y9);
figure,subplot(2,2,1),plot(t,y6),title('T[a1*x1(t)+a2*x2(t)]');grid on
subplot(2,2,2),plot(t,y9),title('a1*T[x1(t)]+a2*T[x2(t)]');grid on
%--------------------time invariant property---------------%
Y2=sin(t-2);
Y3=t.*Y2;
Y4=(t-2).*sin(t-2);
figure,plot(t,Y3,'b--'),title('time invariant');grid on ,text(10*10^5,20,'level2')
hold; plot(t,Y4,'r--'),legend('T[x(t-2)]','y(t-2)',-1)
Expected Graphs:
1. Draw the block diagram notation of a system representing its time invariance
property.
2. Write a MATLAB code for performing the time invariance property of arbitrary
discrete time systems.
3. Draw the block diagram of a discrete time system that represents the proof of its
linearity.
----------------------------------------------------------------------------------------------------------------
4. Write a MATLAB code to see if the system described by the following input-output
relationship is time invariant. Y(n)=x(n)-x(n-1)
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Outcomes:
1. Clearly define linearity and time invariance properties of a discrete time system.
2. Write a MATLAB code for proving the linearity and time invariance property of
arbitrary discrete time systems.
Grading:
Date of
Submission
Marks Awarded Pre-Lab Observations Calculations Post-Lab Viva Total*(10M)
(Max.Marks- Questions (2M) &Graph Questions (2M)
10M) (2M) (2M) (2M)
Remarks
Signature of the
Evaluator with
Date
Notes:
Experiment No.
Finding the Fourier Transform of A Given
Signal and Plotting Its Magnitude And
6 Phase Spectrum
Objectives:
Write a matlab program for finding the Fourier Transform of a given signal and
plot its Magnitude and phase spectrum.
Apparatus:
----------------------------------------------------------------------------------------------------------------
4. Which equation specifies the magnitude and phase of spectral components of FT?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
Expected Graphs:
2. What type of symmetry does the magnitude and phase spectra of FT possess?
----------------------------------------------------------------------------------------------------------------
4. Write a MATLAB program to find the Fourier transform of sinusoidal signal having
frequency 100Hz.
----------------------------------------------------------------------------------------------------------------
Outcomes:
Grading:
Date of
Submission
Marks Awarded Pre-Lab Observations(2 Calculations Post-Lab Viva Total*(1
(Max.Marks- Questions(2 M) &Graph (2M) Questions(2 (2M) 0M)
10M) M) M)
Remarks
Signature of the
Evaluator with
Date
Notes:
Experiment No.
WAVEFORM SYNTHESIS USING LAPLACE
TRANSFORM
7
Regd No:_______________ Date:_______________
Objectives:
Write a matlab program for Wave form Synthesis using Laplace transform
Apparatus:
----------------------------------------------------------------------------------------------------------------
3. Define Region of Convergence (ROC).
----------------------------------------------------------------------------------------------------------------
(A ) Program:
clc;
H = TF( {-5 } , {[1 -1 2] })
%%%%%%
%perform laplace transform
x_a=sym('sin(a*t)+cos(b*t)');
x_a=laplace(x_a);
disp(['(a)x_a(s)=',char(x_a),'=',char(simplify(x_a))]);
%perform inverse laplace trasform
x_b=sym('(a*s^2)/(s^2+b^s)');
x_b=ilaplace(x_b);
disp(['(b)x_b(t)=',char(x_b),'=',char(simplify(x_b))]);
Expected Output:
-5
-----------
s^2 - s + 2
(a)x_a(s)=a/(s^2+a^2)+s/(s^2+b^2)=(a*s^2+a*b^2+s^3+s*a^2)/(s^2+a^2)/(s^2+b^2)
(b)x_b(t)=a*ilaplace(s^2/(s^2+b^s),s,t)=a*ilaplace(s^2/(s^2+b^s),s,t)
----------------------------------------------------------------------------------------------------------------
Outcomes:
1. Know the utility of Laplace transform in the analysis of continuous time LTI system.
2. Explain the effect of different type of poles on the behavior of continuous time LTI
systems.
Grading:
Date of
Submission
Marks Awarded Pre-Lab Observations(2 Calculations Post-Lab Viva Total*(1
(Max.Marks- Questions(2 M) &Graph (2M) Questions(2 (2M) 0M)
10M) M) M)
Remarks
Signature of the
Evaluator with
Date
Notes:
Experiment No.
Generation of Guassian Noise, Computation of its
Mean, M.S.Values and Its Skew, Kurtosis
8 And Psd, Probability Distribution Function
Objectives:
Write a matlab program for generation of Gaussian noise, and computation of its mean,
mean square values, and its psd, probability distribution function.
Apparatus:
2. What is white Gaussian noise? How do you compare it with white uniform noise?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
subplot(3,3,3);hist(pdfuniform1);
title('uniform probability histogram');
subplot(3,3,4);hist(pdfuniform1,100);
title('uniform probability ,100.bin histogram');
pdfmean=5;
pdfstd=7;
pdfnormalss=randn(1,10000)*(pdfstd+pdfmean);
subplot(3,3,5);hist(pdfnormalss);
title('normal distrubution with mean=5,std=7');
subplot(3,3,6);hist(pdfnormalss,100);
title('normal distrubution with mean=5,std=7');
%%%%%%%%%%%%%%%%%%%%%%%%%
x=randn([5 4])
k=kurtosis(x);
k1=skewness(x);
subplot(3,3,1);stem(k);
title('skew');
subplot(3,3,2);stem(k);
title('kurtosis');
%mean
x=normrnd(0,1,100,5);
xbar=(mean(x));
subplot(3,3,3);stem(xbar);
title('mean');
%median
xodd=1:5;
modd=median(xodd)
subplot(3,3,4);stem(modd);
title('odd median');
xeven=1:4;
meven=median(xeven)
subplot(3,3,5);stem(meven);
x=normrnd(0,1,100,6);
title('even median');
%standerd deviation
y=std(x)
subplot(3,3,6);stem(y);
title('standard deviation');
[n,p]=size(x);
x=x-ones(n,1)*mean(x);
y=x'*x/(n-1);
title('standard deviation');
%correlation
x=randn(30,4);
x(:,4)=sum(x,2);
[r,p]=corrcoef(x)
subplot(3,3,7);stem([r,p]);
title('correlation');
[i,j]=find(p<0.05);
[i,j]
%varience
x=[-1 1];
w=[1 3]
v1=var(x);
subplot(3,3,8);stem(v1);
title('varience');
%%%%%%%%%%%%%%%
Fs=1000;
t=0:1/Fs:1;
M=length(t);
w=randn(1,M);
x=cos(2*pi*200*t)+w;
h=spectrum.welch;
psd(h,x,'Fs',Fs);
Expected Graphs:
2. How does the mean and standard deviation affect the shape of Gaussian
distribution?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Outcomes:
Grading:
Date of
Submission
Marks Awarded Pre-Lab Observations Calculations Post-Lab Viva Total*(10M)
(Max.Marks- Questions (2M) &Graph (2M) Questions (2M)
10M) (2M) (2M)
Remarks
Signature of the
Evaluator with
Date
Notes:
Experiment No.
Objectives:
Apparatus:
----------------------------------------------------------------------------------------------------------------
2. What do you understand by uniform sampling?
3. What is aliasing?
----------------------------------------------------------------------------------------------------------------
(A )Program:
clear all;
clc;
t=-100:0.01:100;
fm=.02;
x=cos(2*pi*t*fm);
subplot(221),plot(t,x);title('continuous time signal')
fs1=.02;
n=-2:2;
x1=cos(2*pi*fm*n/fs1);
subplot(222),stem(n,x1,':'),title('discrete time signal with fs<2fm')
fs2=0.04;
n1=-4:4;
x2=cos(2*pi*fm*n1/fs2);
subplot(223),stem(n1,x2),title('discrete time signal with fs=2fm')
hold on
subplot(223),plot(n1,x2,':')
n2=-50:50;
fs3=0.5;
x3=cos(2*pi*fm*n2/fs3);
subplot(224),stem(n2,x3);,title('discrete time signal with fs>2fm')
hold on
subplot(224),plot(n2,x3,':')
%%%%%%%%%%%%%%%%%%%
clear all;
t=-5:0.0001:5;
F1=3;F2=23;
x=cos(2*pi*F1*t)+cos(2*pi*F2*t);
figure(1);plot(t,x);
axis([-0.4 0.4 -2 2]);
xlabel('time t in sec');
ylabel('x(t)');
title('continuous time signal ');
Fs1=1.4*F2;ts1=1/Fs1;
n1=-0.4:ts1:0.4;
xs1=cos(2*pi*F1*n1)+cos(2*pi*F2*n1);
figure(2);stem(n1,xs1);
fs2=0.04;
n1=-4:4;
x2=cos(2*pi*fm*n1/fs2);
subplot(2,2,3);stem(n1,x2);
hold on;
subplot(2,2,3);plot(n1,x2,':');
title('discrete time signal x(n) with fs=2fm');
xlabel('n');
ylabel('x(n)');
n2=-50:50;
fs3=0.5;
x3=cos(2*pi*fm*n2/fs3);
subplot(2,2,4);stem(n2,x3);
hold on;
subplot(2,2,4);plot(n2,x3,':');
title('discrete time signal x(n) with fs>2fm');
xlabel('n');ylabel('x(n)');
Expected Graphs:
----------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Outcomes:
Grading:
Date of
Submission
Marks Awarded Pre-Lab Observations(2 Calculations Post-Lab Viva Total*(1
(Max.Marks- Questions(2 M) &Graph (2M) Questions(2 (2M) 0M)
10M) M) M)
Remarks
Signature of the
Evaluator with
Date
Notes:
Experiment No.
Removal of Noise by Autocorrelation And Cross
10 Correlation
Objectives:
Write a matlab program for removal of noise by autocorrelation & cross correlation
Apparatus:
3. State the formula for determining the signal to noise ratio in decibels?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
N=1024;
f=1;
Fs=200;
n=0:N-1;
x=sin(2*pi*f*n/Fs);
y=x+10*randn(1,N);
subplot(3,1,1);plot(x);
title('pure sinewave');
grid;
subplot(3,1,2);plot(y);
title('y(n), puresinewave + noise');
grid;
Rxy=xcorr(x,y);
subplot(3,1,3);plot(Rxy);
title('cross correlation Rxy');
grid;
%%%%%%%%%%%%%%%%%%%%%%%
N=1024;
f1=1;
Fs=100;
n=0:N-1;
x=sin(2*pi*f1*n/Fs);
subplot(3,1,1);plot(x);title('pure sine wave');
grid;
x1=x+(10*randn(1,N));
subplot(3,1,2);
plot(x1);
title('pure sinewave + noise');
grid;
Rxx=xcorr(x,x1);
subplot(3,1,3);
plot(Rxx);
title('auto correlation Rxx');
%%%%%%%%%%%%%%%%%%%
clc;
%-----------generate sinusoidal signal-------------------------%
t=0:0.1:10;
x = sin(2*pi*t); %generate sinusoidal signal
figure,plot(t,x);title('sinusoidal signal')
%-----------generate gaussian noise-------------------------%
% Y = WGN(1, 201, 10, 'complex');
Y = WGN(1, 101, 10, 'real');
%-----------generate (sinusoidal+noise) signal-------------------------%
X=x+Y;
figure(2),plot(t,X),title('sinusoidal signal+gaussian noise')
s = xcorr2(x,X);
figure(3),plot(s),title('Extraction of sinusoidal signal');
Expected Graphs:
1. When does the cross correlation between two signals become nearly zero?
2. Why can’t we filter out noise from noisy signal? Why should you use correlation to
do so?What are the steps involved in convolution operation?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Outcomes:
1. Write a MATLAB code for removing noise from a noisy periodic signal and calculate
its period.
Grading:
Date of
Submission
Marks Awarded Pre-Lab Observations(2 Calculations Post-Lab Viva Total*(1
(Max.Marks- Questions(2 M) &Graph (2M) Questions(2 (2M) 0M)
10M) M) M)
Remarks
Signature of the
Evaluator with
Date
Notes:
Experiment No.
Objectives:
Apparatus:
2. State the purpose for which the raised cosine filters are normally used.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
[y,t]=rcosflt(ones(10,1),1,8,'fir',.5,6);
%delay=6samples
[y1,t1]=rcosflt(ones(10,1),1,8,'fir',.5,8);
plot(t,y,t1,y1,'--');
peak=t(find(y==max(y)));
peak1=t1(find(y1==max(y1)));
pt=[min(peak),min(peak1)];
Expected Graphs:
(B) Program:
%parametres
delay=3;
dataL=20;
R=0.5;
Fs=8;Fd=1;
PropD=0;
%generate random data at time 0,1Fd,2/Fd....
x=randsrc(dataL,1,[],1245);
tx=[PropD:PropD+dataL-1]./Fd;
%plot data
stem(tx,x);
xlabel('time');ylabel('amplitude');
%set axis&labels
axis([0 30 -1.5 1.5]);
%%%%%%%%%%%%%%%%%%%%%%%
clc;
t=-10:0.1:10;
%--------------------Unit Impulse---------------------%
x1=1;
x2=0;
x =x1.*(t==0); %generate Unit Impulse Signal
subplot(121), plot(x); % plot the generated Unit Impulse Signal
xlabel('t'); ylabel('x(t)'); title('Unit impulse Signal');
%--------------impulse response of raised cosine filter-----------%
y = rcosflt(x,1,8,'fir'); % Same as original example
% y = rcosflt(x,1,8,'fir/sqrt'); % FIR square-root RC filter
% y = rcosflt(x,1,8,'iir'); % IIR raised cosine filter
% y = rcosflt(x,1,8,'iir/sqrt'); % IIR square-root RC filter
% y = rcosflt(x,1,8,'fir'); subplot(122),plot(y)
Expected Graphs:
1. Which MATLAB command returns the impulse response of an FIR type RCF? What is
its syntax?
2. What is the so special about the impulse response of a raised cosine filter?
----------------------------------------------------------------------------------------------------------------
4. Have you heard about ‘root raised cosine filter’? How is it related to RCF?
----------------------------------------------------------------------------------------------------------------
Outcomes:
1. Represent the frequency response and the impulse response of raised cosine filter.
2. Define raised cosine filter and explain the applications in which it is used.
Grading:
Date of
Submission
Marks Awarded Pre-Lab Observations(2 Calculations Post-Lab Viva Total*(1
(Max.Marks- Questions(2 M) &Graph (2M) Questions(2 (2M) 0M)
10M) M) M)
Remarks
Signature of the
Evaluator with
Date
Notes:
Experiment No.
Checking a Random Process for Stationary in Wide
12 Sense
Objectives:
Apparatus:
1. Define random process and distinguish between random variable and random
process
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
Expected Graphs:
1. Prove that the Gaussian random process generated using randn command is a WSS
process using MATLAB.
----------------------------------------------------------------------------------------------------------------
2. Which MATLAB command is used to fold the signal.
----------------------------------------------------------------------------------------------------------------
Outcomes:
1. Develop a MATLAB code for checking if a given random process is wide sense
stationary.
2. Classify the random processes.
Grading:
Date of
Submission
Marks Awarded Pre-Lab Observations(2 Calculations Post-Lab Viva Total*(1
(Max.Marks- Questions(2 M) &Graph (2M) Questions(2 (2M) 0M)
10M) M) M)
Remarks
Signature of the
Evaluator with
Date
Notes:
Experiment No.
13 Gibbs Phenomenon
Objectives:
Apparatus:
3. State the difference between the two words ‘analysis’ and ‘synthesis’, in general
terms.
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
(A ) Program:
t=linspace(-2,2,2000);
u=linspace(-2,2,2000);
sq=[zeros(1,500),2*ones(1,1000),zeros(1,500)];
K=2;
N=[1,3,7,19,49,70];
for n=1:6;
an=[];
for m=1:N(n)
an=[an,2*K*sin(m*pi/2)/(m*pi)];
end;
fN=K/2;
for m=1:N(n)
fN=fN+an(m)*cos(m*pi*t/2);
end;
nq=int2str(N(n));
subplot(3,2,n);
plot(u,sq,'r','LineWidth',2);
hold on;
plot(t,fN,'LineWidth',2);
hold off;
axis([-2 2 -0.5 2.5]);
grid;
xlabel('time');
ylabel('y_N(t)');
title(['N=',nq]);
end;
Expected Graphs:
3. State atleast three important observations that you made by observing all the
synthesized square-wave graphs?
----------------------------------------------------------------------------------------------------------------
Outcomes:
1. Write MATLAB code for observing the Gibbs phenomenon in graphical form.
Grading:
Date of
Submission
Marks Awarded Pre-Lab Observations(2 Calculations Post-Lab Viva Total*(1
(Max.Marks- Questions(2 M) &Graph (2M) Questions(2 (2M) 0M)
10M) M) M)
Remarks
Signature of the
Evaluator with
Date
Notes: