Professional Documents
Culture Documents
INDEX
PAGE
SL NO NAME OF EXPERIMENT DATE
NO
DSP LAB
FAMILIARIZATION OF MATLAB
1 MATRIX ADDITION
2 MATRIX SUBTRACTION
3 MATRIX MULTIPLICATION
4 INVERSE OF A MATRIX
7 RAMP SIGNAL
8 EXPONENTIAL SIGNAL
9 IMPULSE RESPONSE
10 CONVOLUTION
11 LINEAR CONVOLUTION
12 CIRCULAR CONVOLUTION
13 FFT
INTRODUCTION TO SAMPLING
PAGE
SL NO NAME OF EXPERIMENT DATE
NO
DESIGN OF IIR FILTER
COMMUNICATION LAB
INTRODUCTION TO SIMULINK
1 AMPLITUDE MODULATION
2 AM DEMODULATION
FAMILIARIZATION OF MATLAB
MATLAB is an interactive program for doing matrix calculations and has now grown to
a high-level mathematical language that can solve integrals and differential equations
numerically and plot a wide variety of two- and three-dimensional graphs.
A) Definition of Variables
Variables are assigned numerical values by typing the expression directly. The answer
will not be displayed when a semicolon is put at the end of an expression.
- - Subtraction
* - Multiplication
/ - Division
^ - Power operator
' - Transpose
A variable can be assigned using a formula that utilizes these operators and either
numbers or previously defined variables. To determine the value of a previously defined
quantity, type the quantity by itself. If your expression does not fit on one line, use an ellipsis
(three or more periods at the end of the line) and continue on the next line. There are several
predefined variables which can be used at any time, in the same manner as user defined
variables:
i - sqrt(-1)
j - sqrt(-1)
pi - 3.1416...
There are also a number of predefined functions that can be used when defining a
variable. Some common functions that are used in this text are:
abs - magnitude of a number (absolute value for real numbers)
B) Definition of Matrices
MATLAB is based on matrix and vector algebra; even scalars are treated as 1x1 matrices.
Therefore, vector and matrix operations are as simple as common calculator operations.
Vectors can be defined in two ways. The first method is used for arbitrary elements.
v = [1 3 5 7];
creates a 1x4 vector with elements 1, 3, 5 and 7. Note that commas could have been used in
place of spaces to separate the elements. Additional elements can be added to the vector,
v(5) = 8;
yields the vector v = [1 3 5 7 8]. Previously defined vectors can be used to define a new
vector.
The second method is used for creating vectors with equally spaced elements.
t = 0:0.1:10;
creates a 1x11 vector with the elements 0, .1, .2, .3,..., 10. Note that the middle number defines
the increment. If only two numbers are given, then the increment is set to a default of 1.
k = 0:10;
creates a 1x11 vector with the elements 0, 1, 2, ..., 10.Matrices are defined by entering the
elements row by row.
M = [1 2 4; 3 6 8];
C) General Information
MATLAB is case sensitive so "a" and "A" are two different names. Comment statements
are preceded by a "%". On-line help for MATLAB can be reached by typing help for the full
menu or typing help followed by a particular function name or M-file name. For example, help
cos gives help on the cosine function.
The number of digits displayed is not related to the accuracy. To change the format of the
display, type format short e for scientific notation with 5 decimal places, format long e for
scientific notation with 15 significant decimal places and format bank for placing two
significant digits to the right of the decimal.
The commands who and whos give the names of the variables that have been defined in
the workspace. The command length(x) returns the length of a vector x and size(x) returns the
dimension of the matrix x.
D) M-files
M-files are macros of MATLAB commands that are stored as ordinary text files with
the extension "m", that is filename. An M-file can be either a function with input and output
variables or a list of commands.
MATLAB M-files are most efficient when written in a way that utilizes matrix or vector
operations. Loops and if statements are available, but should be used sparingly since
The allowable comparisons between expressions are >=, <=, <, >, ==, and ~=. Suppose that
you want to run an M-file with different values of a variable T. The following command line
within the M-file defines the value.
T = input ('Input the value of T: ')
Whatever comment is between the quotation marks are displayed to the screen when the M-
file is running, and the user must enter an appropriate value.
Double click on icon for MATLAB 6.5. Within about 30 seconds MATLAB will open, a
screen like the picture below appears.
▪ Command Window – This is where you can type commands and usually the answers
(or error messages) appear here too. You will see the cursor flickering after the >>
prompt. This means that MATLAB is waiting for further instructions.
▪ Workspace – if you define new quantities (called variables) their names should be listed
here.
▪ Command History – This is past commands are remembered. If you want to re-run a
previous command or to edit it you can drag it from this window to the command
window to re-run it.
To begin to use MATLAB, click New:M-file from the File menu. This opens a blank window
as shown below.
The M-file is executed using the Run command under the Tools menu. The output signal
appears in Figure Window
MATRIX ADDITION
AIM
Write an algorithm & program to add two matrices and display the result using Matlab.
ALGORITHM
1. Start.
6. Stop.
PROGRAM
clc;
clear all;
close all;
x=input('Enter the First Matrix');
y=input('Enter the Second Matrix');
z=x+y;
disp(z);
OUTPUT
RESULT
Matrix addition is performed and the result is displayed
MATRIX SUBTRACTION
AIM
Write an algorithm& program to add two matrices and display the result using Matlab.
ALGORITHM
1. Start.
6. Stop.
PROGRAM
clc;
clear all;
close all;
X=input(„Enter the first matrix:‟);
Y=input(„Enter the second matrix:‟);
Z=x-y;
disp(z);
OUTPUT
RESULT
MATRIX MULTIPLICATION
AIM
Write an algorithm& program to PERFORM Matrix multiplication and display the result using
Matlab.
ALGORITHM
1. Start.
6. Stop.
PROGRAM
clc;
close all;
clear all;
x=input('Enter the First Matrix :');
y=input('Enter the Second Matrix :');
z=x*y;
disp('Ans:');
disp(z);
OUTPUT
RESULT
Matrix multiplication is performed and result is displayed
AIM
Write an algorithm & program to find the inverse of the matrix using Matlab.
ALGORITHM
1. Start.
5. Stop.
PROGRAM
clc;
clear all;
close all;
x=input(„Enter the matrix:‟);
z=inv(x);
disp(z);
OUTPUT
RESULT
Inverse matrix operation is performed and result is displayed
0 for n ≠ d
3. Ramp signal
The unit ramp signal is denoted as ur(n) and is denoted as
ur(n)=n for n ≥ 0
0 for n < 0
4. Exponential signal
The exponential signal is a sequence of the form
x(n) = an for all n
If the parameter a is real, then x(n) is a real signal. We can express x(n) for various values
of the parameter a.
If the parameter a is complex valued, it can be expressed as
a = rejθ
where r and θ are now the parameters.
5. Sine signal
A discrete time sine signal may be expressed as
x(n) = A sin (n + θ) , - ∞ < n < ∞........... (1)
where n is an integer variable(called the sample number),
A is the amplitude of the signal,
is the frequency in radians per sample, and
θ is the phase in radians.
If instead of we use the frequency variable f defined by
≡2f
The relation (1) becomes
x(n) = A sin (2f n + θ ) , -∞ < n< ∞
The frequency f has dimensions of cycles per sample.
6. Cosine signal
A discrete time cosine signal may be expressed as
x(n) = A cos (n + θ) , - ∞ < n < ∞ ........... (2)
where n is an integer variable(called the sample number),
AIM
To write a program that plot unit impulse signal using MATLAB
ALGORITHM
1. Start.
4. Stop.
PROGRAM
clc;
clear all;
close all;
i=input('Enter the lower limit :');
j=input('Enter the upper limit :');
n=-i:j;
y=[zeros(1,i),1,zeros(1,j)];
stem(n,y);
xlabel('n');
ylabel('y(n)');
title('Impulse Signal');
OUTPUT
RESULT
The unit impulse signal is generated and displayed
AIM
To write a program that plot unit step signal using MATLAB
ALGORITHM
1. Start.
4. Stop.
PROGRAM
clc;
clear all;
close all;
i=input('Enter the limit :');
n=-i:i;
y=[zeros(1,i),1,ones(1,i)];
stem(n,y);
xlabel('n');
ylabel('y(n)');
title('Unit Step Signal');
OUTPUT
Enter limit :10
RESULT
The unit step signal is generated and displayed
RAMP SIGNAL
AIM
To write a program that plot Ramp signal using MATLAB
ALGORITHM
1. Start.
4. Stop.
PROGRAM
clc;
clear all;
close all;
i=input('ENter the limit :');
n=0:i;
y=n;
stem(n,y);
xlabel('n');
ylabel('y(n)');
title('Ramp Signal');
OUTPUT
RESULT
The Ramp signal is generated and displayed
EXPONENTIAL SIGNAL
AIM
To write a program that plot Exponential signal using MATLAB
ALGORITHM
1. Start.
4. Stop.
PROGRAM
clc;
clear all;
close all;
i=input('Enter the limit :');
n=-i:i;
x=exp(1/2*n);
y=exp(-1/2*n);
subplot(2,1,1);
stem(n,x);
xlabel('n');
ylabel('x(n)');
title('Growing Exponential Signal');
subplot(2,1,2);
stem(n,y);
xlabel('n');
ylabel('y(n)');
title('Decaying Exponential Signal');
OUTPUT
Enter the limit :12
RESULT
The Exponential signal is generated and displayed
IMPULSE RESPONSE
AIM
Write a program to evaluate the impulse response of the system described by the differential
equation
ALGORITHM
1.Start
6.Stop
PROGRAM
clc;
close all;
clear all;
x=[0.9 -0.45 0.35 .002];
y=[1 0.71 -0.46 -0.62];
N=input('Enter the no. of samples :');
h=impz(x,y,N);
subplot(2,1,1)
stem(0:N-1,h);
xlabel('samples');
ylabel('amplitude');
title('Impulse Response using "impz" function');
d=[1 zeros(1,N-1)];
h1=filter(x,y,d);
subplot(2,1,2);
stem(0:N-1,h1);
xlabel('samples');
ylabel('amplitude');
title('Impulse Response using "filter" function');
OUTPUT
RESULT
LINEAR CONVOLUTION
AIM
Write an algorithm and program to find the linear convolution of the input sequence using
Matlab.
ALGORITHM
1.Start
5.Plot the graph for input sequences x(n), h(n) and output sequence y(n)
6.Stop
PROGRAM
clc ;
clear all;
close all;
x=input('Enter the first sequence : ');
h=input('Enter the second sequence : ');
k=length(x);
l=length(h);
n=k+l-1;
subplot(3,1,1);
stem(0:k-1,x);
title('Input Sequence x(n)');
xlabel('No. of samples');
ylabel('x(n)');
subplot(3,1,2);
stem(0:l-1,h);
xlabel('No. of samples');
ylabel('h(n)');
title('Impulse Response h(n)');
y=conv(x,h);
disp('Output=');
disp(y);
subplot(3,1,3);
stem(0:n-1,y);
title('Convolved Signal y(n)=x(n)*h(n)');
xlabel('No. of samples');
ylabel('y(n)');
OUTPUT
Enter the first sequence: [3 5 2 6 7 8 9]
Enter the second sequence: [4 6 2 3 8 9 1 4]
Output=
12 38 44 55 107 159 180 174 174 168 175 117 41 36
RESULT
Obtained linear convolution of the given input sequence and plotted the sequences
CIRCULAR CONVOLUTION
AIM
Write an algorithm and program to find the circular convolution of the input sequence using
Matlab.
ALGORITHM
1.Start
5.Plot the graph for input sequences x(n), h(n) and output sequence y(n)
6.Stop
PROGRAM
clc;
close all;
x=input('Enter the first sequence : ');
h=input('Enter the second sequence : ');
k=length(x);
l=length(h);
n=max(l,k);
subplot(3,1,1);
stem(0:k-1,x);
title('Input Sequence x(n)');
xlabel('No. of samples');
ylabel('x(n)');
subplot(3,1,2);
stem(0:l-1,h);
xlabel('No. of samples');
ylabel('h(n)');
title('Impulse Response h(n)');
y=cconv(x,h,n);
disp('Output =');
disp(y);
subplot(3,1,3);
stem(0:n-1,y);
title('Convolved Signal y(n)=x(n)*h(n)');
xlabel('No. of samples');
ylabel('y(n)');
OUTPUT
Output =
RESULT
Obtained circular convolution of the given input sequence and plotted the sequences
The discrete Fourier Transform (DFT) of a discrete time signal x(n) is a finite duration
discrete frequency sequence. The DFT sequence is denoted by X(k). The DFT is obtained by
sampling one period of the Fourier Transform X() of the signal x(n) at a finite number of
frequency points. This sampling is conventionally performed at N equally spaced points in the
period = −
The N-point DFT of a finite duration sequence x(n) of length L, where N L, is defined as
The Fast Fourier transform (FFT) is a method for computing the DFT with reduced
number of calculations. The computation efficiency is achieved if we adopt a divide and
conquer approach. This approach is based on the decomposition of an N-point DFT into
successively smaller DFTs. This basic approach leads to a family of an efficient computation
algorithm known as FFT algorithm.
In radix-2 FFT the N-point sequence is decimated into 2-point sequences and the 2- point
DFT for each decimated sequence is computed. From the results of 2-point DFTs, the 4-point
DFTs can be computed. From the result of 4-point DFT, the 8-point DFT can be computed and
so on, until we get N-point DFT.
AIM
Develop a program to find the FFT of the given signal and plot the graph.
ALGORITHM
1.Start
6.Stop
PROGRAM
clc;
close all;
clear all;
fs=1000;
Ts=1/fs;
n=2000;
t=(0:n-1)*Ts;
f1=20;
f2=40;
f3=70;
x1=6*sin(2*pi*f1*t);
x2=5*sin(2*pi*f2*t);
x3=8*sin(2*pi*f3*t);
x=x1+x2+x3;
figure(1);
subplot(3,1,1);
plot(t,x1);
xlabel('Time');
ylabel('Amplitude');
title('20Hz Signal');
subplot(3,1,2);
plot(t,x2);
xlabel('Time');
ylabel('Amplitude');
title('40Hz Signal');
subplot(3,1,3);
plot(t,x3);
xlabel('Time');
ylabel('Amplitude');
title('70Hz Signal');
figure(2);
subplot(2,1,1);
plot(t,x);
xlabel('Time');
ylabel('Amplitude');
title('Mixed Signal X(t)');
f=fs*(1:(n/2))/n;
y=fft(x);
p1=abs(y/n);
p2=p1(1:n/2);
subplot(2,1,2);
plot(f,p2);
axis([0 500 0 5]);
xlabel('Frequency');
ylabel('|X(t)|');
title('Amplitude spectrum of Mixed Signal X(t)');
OUTPUT
RESULT
Generated the FFT of the mixed signal wave signal and verified the frequency
components.
INTRODUCTION TO SAMPLING
If the highest frequency obtained in an analog signal xa(t) is fmax. The sampling rate
fs = fmax is called the Nyquist rate.
If the sampling rate is higher than the Nyquist rate, it is called Over-sampling. On the
other hand, if the sampling rate is lower than the Nyquist rate, it is called under-sampling.
Finally, if the sampling rate is exactly equal to the Nyquist rate, it is called critical sampling.
Sampling theorem
“A continuous-time signal may be completely represented in its samples and recovered
back if the sampling if the sampling frequency is fs 2fmax. Here fs is the sampling frequency
and fmax is the maximum frequency present in the signal.”
AIM
Write a program to sample a signal having frequency 0.02 and plot the output wave forms of
the three conditions given below
1) fs=2*fm
2) fs>2*fm
3) fs<2*fm
PROGRAM
clc;
clear all;
close all;
t=-100:0.01:100;
fm=0.02;
x=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,x);
xlabel(' time in seconds');
ylabel('x(t)');
title('Original Signal');
fs1=0.02; %fs<2fm%
n1=-2:2;
x1=cos(2*pi*fm*n1/fs1);
subplot(2,2,2);
stem(n1,x1);
hold on;
subplot(2,2,2);
plot(n1,x1,':');
xlabel('n1');
ylabel('x(n1)');
title('Discrete Time Signal for fs<2fm');
fs2=0.04; %fs=2fm%
n2=-4:4;
x2=cos(2*pi*fm*n2/fs2);
subplot(2,2,3);
stem(n2,x2);
hold on;
plot(n2,x2,':');
xlabel('n2');
ylabel('x(n2)');
title('Discrete Time Signal for fs=2fm');
fs3=0.5; %fs3>2fm%
n3=-50:50;
x3=cos(2*pi*(fm/fs3)*n3);
subplot(2,2,4);
stem(n3,x3);
hold on;
plot(n3,x3,':');
xlabel('n3');
ylabel('x(n3)');
title('Discrete Time Signal for fs>2fm');
OUTPUT
RESULT
AIM
Write a program to design an IIR Butterworth Lowpass filter and plot its amplitude &
phase responses
ALGORITHM
1. Start.
2. Enter pass band frequency, stop band frequency, pass band ripple, minimum stop band
attenuation and sampling frequency.
3. Find normalized pass band frequency (Wp) and normalized stop band frequency (Ws).
4. Find order and cut off frequency of the butterworth filter using function “buttord‟.
7. Find out gain (in dB) and pass angle in (in radian) using frequency response.
9. Stop.
PROGRAM
clc;
close all;
clear all;
fp=input('Enter the pass band frequency :');
fs=input('Enter the stop band frequency :');
f=input('Enter the sampling frequency :');
rp=input('Enter the passband ripple :');
rs=input('Enter the stopband ripple :');
wp=fp/f;
ws=fs/f;
[N,Wn]=buttord(wp,ws,rp,rs);
[b,a]=butter(N,Wn,'low');
n=0:0.1:pi;
[h,ohm]=freqz(b,a,n);
gain=20*log10(abs(h));
ang=angle(h);
subplot(2,1,1);
plot(ohm/pi,gain);
grid;
xlabel('Normalized Frequency');
ylabel('gain(dB)');
title('Frequency Response');
subplot(2,1,2);
plot(ohm/pi,ang);
grid;
xlabel('Normalised frequency');
ylabel('Phase');
title('Phase Response');
OUTPUT
Enter passband frequency :400
Enter stopband frequency :800
Enter sampling frequency :2000
Enter passband ripple:.4
RESULT
Designed an IIR Butterworth Low pass filter and plotted its responses
AIM
Write a program to design an IIR Butterworth High Pass Filter and plot its amplitude &
phase responses and pole-zero plot.
ALGORITHM
1. Start.
2. Enter pass band frequency, stop band frequency, pass band ripple, minimum stop band
attenuation and sampling frequency.
3. Find normalized pass band frequency (Wp) and normalized stop band frequency (Ws).
4. Find order and cut off frequency of the butterworth filter using function “buttord‟.
7. Find out gain (in dB) and pass angle in (in radian) using frequency response.
9. Stop.
PROGRAM
clc;
clear all;
close all;
Fp=input('Enter passband frequency :');
Fs=input('Enter stopband frequency :');
Ft=input('Enter sampling frequency :');
Rp=input('Enter passband attenuation :');
Rs=input('Enter Min stopband attenuation :');
Wp=(2*Fp)/Ft;
Ws=(2*Fs)/Ft;
[N,Wn]=buttord(Wp,Ws,Rp,Rs);
[b,a]=butter(N,Wn,'high');
w=[0:0.01:pi];
[h,omega]=freqz(b,a,w);
gain=20*log10(abs(h));
ang=angle(h);
subplot(2,1,1);
plot(omega/pi,gain);grid;
xlabel('Normalised frequency(Hz)');
ylabel('gain in dB');
title('Frequency response');
subplot(2,1,2);
plot(omega/pi,ang);grid;
xlabel('Normalised frequency(Hz)');
ylabel('Phase in radians');
title('Phase response');
OUTPUT
Enter passband frequency :500
RESULT
Designed an IIR Butterworth High pass filter and plotted its response.
AIM
To design an IIR Chebyshev Low Pass Filter and plot its response.
ALGORITHM
1. Start.
2. Enter pass band frequency, stop band frequency, pass band ripple, minimum stop band
attenuation and sampling frequency.
3. Find normalized pass band frequency (Wp) and normalized stop band frequency (Ws).
4. Find order and cut off frequency of the chebyshev filter using function “cheb1ord‟.
7. Find out gain (in dB) and pass angle in (in radian) using frequency response.
9. Stop.
PROGRAM
clc;
close all;
clear all;
fp=input('Enter the pass band frequency :');
fs=input('Enter the stop band frequency :');
f=input('Enter the sampling frequency :');
rp=input('Enter the passband ripple :');
rs=input('Enter the stopband ripple :');
wp=fp/f;
ws=fs/f;
[N,Wn]=cheb1ord(wp,ws,rp,rs);
[b,a]=cheby1(N,rp,Wn,'low');
n=0:0.1:pi;
[h,ohm]=freqz(b,a,n);
gain=20*log10(abs(h));
ang=angle(h);
subplot(2,1,1);
plot(ohm/pi,gain);
grid;
xlabel('Normalized Frequency');
ylabel('gain(dB)');
title('Frequency Response');
subplot(2,1,2);
plot(ohm/pi,ang);
grid;
xlabel('Normalised frequency');
ylabel('Phase');
title('Phase Response');
OUTPUT
Enter passband frequncy : 400
Enter stopband frequncy : 700
Enter sampling frequncy : 2000
Enter passband attenuation : .5
Enter min. stopband attenuation: 40
RESULT
Designed IIR Chebyshev Low Pass Filter and plotted its response.
AIM
To design an IIR Chebyshev High Pass Filter and plot its response.
ALGORITHM
1. Start.
2. Enter pass band frequency, stop band frequency, pass band ripple, minimum stop band
attenuation and sampling frequency.
3. Find normalized pass band frequency (Wp) and normalized stop band frequency (Ws).
4. Find order and cut off frequency of the chebyshev filter using function “cheb1ord‟.
7. Find out gain (in dB) and pass angle in (in radian) using frequency response.
9. Stop.
PROGRAM
clc;
close all;
clear all;
fp=input('Enter the pass band frequency :');
fs=input('Enter the stop band frequency :');
f=input('Enter the sampling frequency :');
rp=input('Enter the passband ripple :');
rs=input('Enter the stopband ripple :');
wp=fp/f;
ws=fs/f;
[N,Wn]=cheb1ord(wp,ws,rp,rs);
[b,a]=cheby1(N,rp,Wn,'high');
n=0:0.1:pi;
[h,ohm]=freqz(b,a,n);
gain=20*log10(abs(h));
ang=angle(h);
subplot(2,1,1);
plot(ohm/pi,gain);
grid;
xlabel('Normalized Frequency');
ylabel('gain(dB)');
title('Frequency Response');
subplot(2,1,2);
plot(ohm/pi,ang);
grid;
xlabel('Normalised frequency');
ylabel('Phase');
title('Phase Response');
OUTPUT
Enter passband frequency: 700
Enter stopband frequency: 400
Enter sampling frequency:2000
RESULT
Designed IIR Chebyshev High Pass Filter and plotted its response.
COMMUNICATION LAB
INTRODUCTION TO SIMULINK
Typically, the MATLAB m-file ode45 is used to solve sets of linear and nonlinear
ordinary differential equations. The ``traditional'' numerical methods approach is used, e.g.
supply the equations to be solved in a function file, and use a general purpose equation solver
(linear or nonlinear algebraic, linear or nonlinear differential equation, etc.) which ``calls'' the
supplied function file to obtain the solution. One of the reasons why MATLAB is relatively
easy to use is that the ``equation solvers'' are supplied for us, and we access these through a
command line interface (CLI) (aka the MATLAB prompt, >>). However, SIMULINK uses a
graphical user interface (GUI) for solving process simulations. Instead of writing MATLAB
code, we simply connect the necessary ``icons'' together to construct the block diagram. The
``icons'' represent possible inputs to the system, parts of the systems, or outputs of the system.
SIMULINK allows the user to easily simulate systems of linear and nonlinear ordinary
differential equations. A good background in matrix algebra and lumped parameter systems as
well as an understanding of MATLAB is required, and we highly recommend that the student
thoroughly reads and works through this tutorial. Many of the features of SIMULINK are
user-friendly due to the icon-driven interface, yet it is important to spend some time
experimenting with SIMULINK and its many features. Dynamic simulation packages (such
as MATLAB, SIMULINK, etc.) are being used more and more frequently in the chemical
process industries for process simulation and control system design. After completing this
tutorial, the student should be able to ``build'' and simulate block diagram representations of
dynamic systems.
SIMULINK is an icon-driven state of the art dynamic simulation package that allows
the user to specify a block diagram representation of a dynamic process. Assorted sections of
the block diagram are represented by icons which are available via various "windows" that the
user opens (through double clicking on the icon). The block diagram is composed of icons
representing different sections of the process (inputs, state-space models, transfer functions,
outputs, etc.) and connections between the icons (which are made by "drawing" a line
connecting the icons). Once the block diagram is "built", one has to specify the parameters in
the various blocks, for example the gain of a transfer function. Once these parameters are
specified, then the user has to set the integration method (of the dynamic equations), stepsize,
start and end times of the integration, etc. in the simulation menu of the block diagram window.
In order to use SIMULINK the student must ``start'' a MATLAB session (click on
the MATLAB button). Once MATLAB has started up, type simulink (SMALL LETTERS!)
at the MATLAB prompt (>>) followed by a carriage return (press the return key). A
SIMULINK window should appear shortly, with the following icons: Sources, Sinks,
Discrete, Linear, Nonlinear, Connections, Extras (this window is shown in Figure 2). Next, go
to the file menu in this window and choose New in order to begin building the block diagram
representation of the system of interest.
Saving a Model
We can save a model by choosing either the Save or Save As command from the File menu.
Simulink saves the model by generating a specially formatted file called the model file (with
the .mdl extension) that contains the block diagram and block properties
all platforms). On a Microsoft Windows system, the Print menu item prints the block
diagram in the current window.
Selecting Objects
Many model building actions, such as copying a block or deleting a line, require that you
first select one or more blocks and lines (objects).
Connecting Blocks
Simulink block diagrams use lines to represent pathways for signals among blocks in a model
(see Annotating Diagrams for information on signals). Simulink can connect blocks for you or
we can connect the blocks our self by drawing lines from their output ports to their input ports.
Annotations provide textual information about a model. We can add an annotation to any
unoccupied area of our block diagram
Creating Subsystems
As our model increases in size and complexity, we can simplify it by grouping blocks into
subsystems.
we can create a subsystem in two ways:
➢ Add a Subsystem block to your model, then open that block and add the blocks it
contains to the subsystem window.
➢ Add the blocks that make up the subsystem, then group those blocks into a
subsystem.
AMPLITUDE MODULATION
AIM
Simulate an amplitude modulator with modulation index,
(a) m =1.
(b) m >1.
(c) 0 < m <1.
Using SIMULINK
THEORY
In amplitude modulation the amplitude of a carrier signal is varied by modulating voltage,
whose frequency is invariably lower than that of carrier. That is the amplitude of carrier is
made proportional to the instantaneous amplitude of the modulating voltage.
Let the carrier voltage and the modulating voltage, Vc and Vm respectively be represented as
Vc = Ac sin c t ….. (1)
Vm= Am sin m t ..… (2)
From the definition of amplitude modulation, it follows that maximum amplitude Ac of the
unmodulated carrier will have to be made proportional to the instantaneous modulating voltage
Am sin m t when the carrier is amplitude modulation. Hence,
A = Ac + Vm
= Ac + Am sin m t
= Ac [1+ Am / Ac sin m t]
= Ac [1 + m sin m t]....... (3)
Where „m‟ is called the modulation index, which is a number lying between 0 & 1 and it is
often expressed as percentage and called percentage modulation.
If m= 1 :100% modulation.
m>1 : over modulation.
0<m<1 : perfect modulation
BLOCK DIAGRAM
RESULT
Message signal
Carrier Signal
Message signal
Carrier Signal
Message signal
Carrier Signal
AM DEMODULATION
AIM
Simulate an amplitude demodulator using SIMULINK
THEORY
Demodulation is the process of extracting the base band message from the carrier so
that it may be processed and interpreted by the intended receiver. There are two types of
demodulation techniques
1) coherent detection
2) non–coherent detection
Coherent Detection
Coherent demodulation requires knowledge of the transmitted carrier frequency and phase
at the receiver. Product detector is used commonly. It is commonly. It is also called phase
detector. It contains a down converter circuit, which converts the input band pass signal to a
base band signal
Let x(t) = (1+ m(t)) cos ct
Let m = vc =1 and the message and carrier be in cosine form.
In product detector demodulator, x(t) is multiplied with the same carrier.
i.e.,y(t) = x(t) cos ct
= [(1+m(t)) cos ct] cos ct
= (1+m(t)) cos2 ct
= (1+m(t)) (cos 2ct + 1)
= [1+m(t)+ cos 2ct+ m(t)cos 2ct]
The message signal can be reconstructed by neglecting the constant terms and by using
lowpass filter to eliminate the higher frequency components.
Non-Coherent Detection
In second method AM signal is demodulated using non – coherent envelope detectors
which are easy and cheap to build. An ideal envelope detector is circuit that has an output
proportional to the real envelope of the input signal.
Envelope detectors are useful when the input signal power is at least 10dB greater
than the noise power, where as product detectors are able to process AM signals with input
signal to noise ratios well below 10dB.
BLOCK DIAGRAM
RESULT
Carrier Signal
Demodulated signal
FREQUENCY MODULATION
AIM
Simulate a frequency modulator using SIMULINK.
THEORY
It is the system in which the amplitude of the modulated carrier is kept constant while
its frequency is varied by modulating signal. The amount by the carrier frequency are varied
from its un–modulated value is called the deviation, is made proportional to the instantaneous
values of the modulating signal.
The instantaneous value of the frequency is given by,
fi(t)= fc + kf m(t) ...................... (1)
Where kf m(t) = Time varying component proportional to m(t)
m(t) = modulating signal
kf =Frequency sensitivity of modulator
=k fc
k = proportionality constant
fc = carrier frequency.
BLOCK DIAGRAM
RESULT
FM modulator passband parameters
Carrier frequency (Hz) : 5
Initial phase (Rad) : 0
Modulation constant (Hz per volt) : 1
Sample time (s) : 0.001
Symbol interval : Inf
Message signal
FM output Signal
AIM
Simulate a pulse amplitude modulator using SIMULINK.
THEORY
PAM is the simplest form of pulse modulation. In PAM, the signal is sampled at regular
intervals and each sample is made proportional to the amplitude of the signal at the instant of
sampling. Two ways of sampling can be employed in PAM
(a)Natural Sampling
(b)Flat-topped Sampling
In natural sampling, the sampling waveform consist of a train of pulses having duration
„‟separated by the sampling period „Ts‟. The base band signal is m(t) and the sampled signal
s(t)m(t) will follow the waveform m(t). Naturally sampled signal can be recovered by passing
it through a low pass filter.
BLOCK DIAGRAM
RESULT
Message signal parameters
Sine type: Time based
Amplitude: 2
Bias: 0
Frequency[rad/sec]: 2*pi*0.2
Phase[rad]: 0
Sample time: 1/100
Message signal
PAM Output
AIM
Simulate an FSK modulator using SIMULINK
THEORY
In FSK, the carrier frequency is shifted in steps or levels corresponding to the levels
of the digital modulating signal. FSK is a method of frequency modulation where a bit
„1‟ is represented by a „mark‟ and bit‟0‟ by „space‟. In this system two different frequencies
are used as carriers‟ .One frequency is transmitted for a „mark‟ and another frequency is
transmitted for a „space‟.
Binary 0= e0(t) =A0cos (2f0 t + 0)
Binary 1= e1(t) =A1cos (2f1 t + 1)
BLOCK DIAGRAM
RESULT
Switch Parameters
Criteria for passing first input: U2>threshold
Threshold: 0
Space signal
Mark signal
1. Pulse Width=25%
Message signal
FSK Output
2. Pulse Width=50%
Message signal
FSK Output
3. Pulse Width=75%
Message signal
FSK Output