0% found this document useful (0 votes)
25 views22 pages

Signals Lab Record (MK)

Uploaded by

220301021
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views22 pages

Signals Lab Record (MK)

Uploaded by

220301021
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

DEPARTMENT OF BIOMEDICAL ENGINEERING

RAJALAKSHMI ENGINEERING COLLEGE


THANDALAM, CHENNAI – 602 105

BM19541-SIGNALS & SYSTEMS ANALYSIS LAB

V SEMESTER

DEPARTMENT OF BIOMEDICAL ENGINEERING


RAJALAKSHMI ENGINEERING COLLEGE

INDEX
EX. DATE NAME OF MARKS TEACHER’S
NO. EXPERIMENT SIGN
1. GENERATIONS OF DISCRETE
TIME SIGNAL
2. GENERATIONS OF CONTINOUS
TIME SIGNAL
3. BASIC OPERATIONS ON
SIGNALS
4. CONVOLUTION OF TWO
DISCRETE TIME SIGNALS
5. STABILITY OF DISCRETE TIME
SYSTEM
6. STABILITY OF CONTINOUS
TIME SYSTEM
7. VERIFICATION OF SAMPLING
THEOREM
8. GENERATION OF
BIOSIGNALS(EMG)

INTRODUCTION TO MATLAB

AIM: To study the basic operations of MATLAB.

What is MATLAB ?
It stands for matrix laboratory. It is developed by the company, the MAT works, INC USA.It
is an interactive integrated, interrupted for numerical calculation, and symbolic calculation
and and scientific visualization. It is a programming language.
KEY FEATURES OF MATLAB:
High level language for technical computing development. Development environment for
managing codes, files & data. Interactive tools for interactive operation, design and problem
solving. Mathematical function for linear, algebra, statistical Fourier analysis, filtering,
optimization and numerical integration. 2D and 3D graphics function for visualizing data.
Tools for building custom user interface (CUI). Programming and developing is faster
because there is no administrative task such as declaring variable and allocating memory.
STARTING OF MATLAB: Double click the MATLAB icon which is on the desktop to
get a MATLAB commandprompt.

QUITING MATLAB:
Type quit or exit in the MATLAB command prompt. Quit or exit

WHERE AND HOW TO START WRITING PROGRAM :


As with any other programming language, when one wishes to write actual program. They
must begin same form of editor. MATLAB has built in editor, that debugging the MATLAB.
Typing (edit) as MATLAB prompt will cause the editor which typically looks like text editor
There are two types of program which typically looks like text editor.

There are two types of program which are mainly written.

>Script (It is called M-file because of their m extension )

>Function SCRIPT

script are program that when executed will have each of it command executed if they were
ended, the MATLAB command prompt script can use variable that are currently in the work
space.

FUNCTION:
Function are program that when executed written a specified output obtain from a given set
of input, function can see in variable , that are passed to it output and will only written
variable that are specified as output.
To make the user to write the program easier MATLAB include many standard function ,
each function is a block of port that accomplishes a specific task, MATLAB which contains
all of the standard function such as sine, cosine, log, exponential ,square root as well as many
other function

Eg: >> sin(pi/4)

Output: 0.707

PLOTTING :
It is also easy to create plot in MATLAB .
Suppose you want to plot the sine wave as function of time, first make the time vector

Eg: >>t=0;2.5;7

>>r=sin

>>plot(t,y)

>>stem(t,y)

USING M-FILE IN MATLAB :


M-file allow user to write function using MATLAB command. This is especially useful for
statement like loop etc., which can be incorporated to allow it to operate it to regular
program. To create an M-file just go to new in the file menu to the new document to create
text file with the little of extension . M to run the file. Click run button in the M-file editor.

BASIC OPERATIONS:
RESULT:

Thus the basic operations of MATLAB were studied.


EXP N0: 1 DATE:

GENERATION OF DISCRETE TIME SIGNALS

AIM:

To write a matlab program for generation of discrete time signals.

APPARATUS REQIRED:

PC, Matlab Software

PROGRAM:
clc; clear
all;
close all;

%sine wave generation


f=0.5; n=0:0.01:3;
x=sin(2*pi*f*n);
subplot(3,2,1);
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('sinusoidal signal');

%cosine wave generation


f=0.5; n=0:0.01:3;
x=cos(2*pi*f*n);
subplot(3,2,2);
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('cosine signal');

%square wave generation


f=0.5; n=0:0.01:3;
x=square(n);
subplot(3,2,3);
stem(x,n);
xlabel('time');
ylabel('amplitude');
title('square wave');

%sawtooth wave generation


f=0.5; n=0:0.01:3;
x=sawtooth(n);
subplot(3,2,4);
stem(n,x);
xlabel('time');
ylabel('amplitude'
);
title('sawtooth wave');

%exponential rising wave generation


a=0.5; n=0:3; e=exp(a*n);
subplot(3,2,5); stem(n,e);
xlabel('time'); ylabel('amplitude');
title('exponential rising wave');

%exponential decaying wave generation


a=0.5; n=0:3; e=exp(-a*n);
subplot(3,2,6); stem(n,e); xlabel('time');
ylabel('amplitude');
title('exponential decaying wave');

OUTPUT:

RESULT:
Thus a Matlab program for generation of discrete time signals is written and executed
successfully.

EXP N0: 2 DATE:

GENERATION OF CONTINUOUS TIME SIGNALS


AIM:

To write a Matlab program for generation of continuous time signals.

APPARATUS REQIRED:

PC, Matlab Software

PROGRAM:
clc; clear
all; close
all;

%sine wave generation


t=0:0.01:10; f=1;
y=sin(2*pi*f*t);
subplot(3,2,1);
plot(t,y); xlabel('time')
ylabel('amplitude')
title('sine wave')

% cosine wave generation


t=0:0.01:10; f=1;
y=cos(2*pi*f*t);
subplot(3,2,2);
plot(t,y);
xlabel('time')
ylabel('amplitude')
title('cosine wave')

% square wave generation


t=0:0.01:10; f=1;
y=square(t);
subplot(3,2,3);
plot(t,y);
xlabel('time')
ylabel('amplitude')
title('square wave')

% sawtooth wave generation


t=0:0.01:10; f=1;
y=sawtooth(t);
subplot(3,2,4);
plot(t,y);
xlabel('time')
ylabel('amplitud
e')
title('sawtooth wave')
% exponential rising wave generation
t=0:0.01:10; a=2; y=exp(a*t);
subplot(3,2,5); plot(t,y);
xlabel('time') ylabel('amplitude')
title('exponential rising wave')

% exponential decaying wave generation


t=0:0.01:10; a=2; y=exp(-a*t);
subplot(3,2,6); plot(t,y);
xlabel('time') ylabel('amplitude')
title('exponential decaying wave')

OUTPUT:

RESULT:
Thus a matlab program for generation of continuous time signals is written and executed
successfully.

EXP N0: 3 DATE:

BASIC OPERTIONS ON SIGNALS

AIM:
To write a matlab program to perform operations on signals.
APPARATUS REQIRED:
PC, Matlab Software

ALGORITHM:
Time shifting
1. Define the number of samples (N) and range of values for n.
2. Define the amplitude at every instant of n.
3. Generate the signal for the defined amplitude and n values.
4. Display the generated signal.
5. Apply the time shifting operation by adding or subtracting constants.
6. Generate the signal for the defined amplitude and newly assigned n values. 7. Display the time
shifted signal.
Time folding
1. Define the number of samples (N) and range of values for n.
2. Define the amplitude at every instant of n.
3. Generate the signal for the defined amplitude and n values.
4. Display the generated signal.
5. Apply the folding operations by interchanging left side of the amplitude to rightside and vice versa.
Also change the sign of the time instants.
6. Generate the signal for the defined amplitude and newly assigned n values.
7. Display the folded signal.
Amplitude Scaling
In the amplitude scaling, a signal y(n) resulting from a signal x(n), on amplitude scaling by area value
A becomes: y(n)=k x(n)

PROGRAM: clc;
clear all; close all;
%Amplitude scaling
n =0:5; x=[1,-
1,0,0,5,4];
a=2; y=a*x;
subplot(3,2,1)
stem(n,y);
xlabel('time')
ylabel('Amplitude')
title('Amplitude scaling')

%Time scaling a=0.5;


m=n/a; subplot(3,2,2);
stem(m,x);
xlabel('time')
ylabel('Amplitude')
title('Time scaling')

%Time shifting m=n+2;


subplot(3,2,3);
stem(m,x); xlabel('time')
ylabel('Amplitude')
title('Time shifting')

%Time folding m=-


fliplr(n); x1=fliplr(x);
subplot(3,2,4);
stem(m,x1); xlabel('time')
ylabel('Amplitude')
title('Time folding')

OUTPUT:

RESULT:
Thus a Matlab program to perform operations on signals is written and executed successfully.
DATE:

EXP N0: 4

CONVOLUTION OF TWO DISCRETE SIGNALS

AIM: To write a Matlab program to perform convolution of two


signals.

APPARATUS REQIRED:
PC, Matlab Software.

PROGRAM:
%convolution of sequence

n=-2:1; x=[1 2 -1 3];

subplot(3,1,1); stem(n,x);

xlabel('time');

ylabel('amplitude');

title('x(n)'); axis([-3

3 -2 4]); m=-1:2;

h=[2 -1 1 4];

subplot(3,1,2);

stem(m,h);

xlabel('time');

ylabel('amplitude');

title('h(n)'); axis([-3 3

-2 5]); k=-3:3;

y=conv(x,h);

subplot(3,1,3);

stem(k,y);

xlabel('time');

ylabel('amplitude');

title('y(n)=x(n)*h(n)');

axis([-3 3 -4 14]);
OUTPUT:

RESULT:
Thus a Matlab program to perform convolution of two signals is written and executed
successfully.

EXP N0: 5
DATE:

STABILITY OF A DISCRETE TIME SYSTEM

AIM:
To write a Matlab program to check the stability of a discrete time system.

APPARATUS REQIRED:
PC, Matlab Software

ALGORTHM:
1. Get the coefficients of numerator polynomial of transfer function.

2. Get the coefficients of denominator polynomial of transfer function.

3. Compute the transfer function using numerator and denominator coefficients.

4. Calculate the values of poles and zeros.

5. Display the pole-zero plot

6. Find the stability of the system using the location of poles.

7. Display the results.

PROGRAM:
%stability of a system num=[0.3
0.6 0.2]; den=[1 0.2 0.8];
H=tf(num,den);
zplane(num,den); if(isstable(H))
display('The system is stable')
else display('The system is
unstable') end
OUTPUT:

RESULT:
Thus a Matlab program to check the stability of a discrete time system is written and executed
successfully.
EXP N0: 6

STABILITY OF A CONTINUOUS TIME SYSTEM


DATE:

AIM:
To write a Matlab program to check the stability of a continuous time system.

APPARATUS REQIRED:
PC, Matlab Software

ALGORTHM:
1. Get the coefficients of numerator polynomial of transfer function.

2. Get the coefficients of denominator polynomial of transfer function.

3. Compute the transfer function using numerator and denominator coefficients.

4. Model the system function into zero-pole-gain system model.

5. Display the pole-zero plot

6. Find the stability of the system using the location of poles.

7. Display the results.

PROGRAM:
%Stability of Continuous System
num=[1]; den=[1 6 11 6];
H=tf(num,den); pzmap(H);

if (isstable(H)) display('The
system is stable') else
display('The system is unstable')
end
OUTPUT:

RESULT:
Thus a Matlab program to check the stability of a continuous time system is written and
executed successfully.
EXP N0: 7 DATE:

VERIFICATION OF SAMPLING THEOREM

AIM:
To write a matlab program to verify Sampling theorem.

APPARATUS REQIRED:
PC, Matlab Software

THEORY:

The word sampling refers to the conversion of the continuous time signal into discrete time
signal. The CTS is converted into discrete signal by taking its value or samples at uniform
space points in time. The time between the two consecutive samples is called the sampling
theorem.

ALGORITHM:
1. Plot an arbitrary signal.
2. Convert the continuous time signal.
3. Then it is converted to discrete time signal, using sampling theorem.
4. Check the effect of aliasing, this can be expressed as fs>2fmax.
5. Check the Nyquist rate by taking fs=2fmax.
6. Check the sampling theorem fs>2fmax.
7. Plot the output waveform. 8. Stop.

PROGRAM:
% Program for CT Signals
t=-100:0.01:100;
fm=0.02;
x=cos(2*pi*fm*t);
subplot(2,2,1); plot(t,x);
xlabel('time');
ylabel('amplitude');
title('CT signals');
% Program for aliasing effect
n=-10:10; fs1=0.03;
x1=cos(2*pi*fm*n/fs1);
subplot(2,2,2); stem(n,x1);
xlabel('time');
ylabel('amplitude');
title('Aliasing Effect');
hold on;
plot(n,x1,'r');
% Program for nyquist effect
fs2=0.04;
x2=cos(2*pi*fm*n/fs2);
subplot(2,2,3);
stem(n,x2); xlabel('time');
ylabel('amplitude');
title('Nyquist effect');
hold on;
plot(n,x2,'g');
% Program for Reconstruction
m=-100:100; fs3=1;
x3=cos(2*pi*fm*m/fs3);
subplot(2,2,4);
stem(m,x3); xlabel('time');
ylabel('amplitude');
title('Reconstruction');
hold on;
plot(m,x3,'v');

OUTPUT:

RESULT:
Thus a Matlab program to verify sampling theorem is written and executed successfully.
EXP N0: 8 DATE:

GENERATION OF EMG SIGNALS

AIM:
To write a Matlab program to generate EMG signals.

APPARATUS REQUIRED:
PC, Matlab Software

PROGRAM:
% Parameters
fs = 1000; % Sampling frequency (Hz)
duration = 2; % Duration of the signal (seconds)
t = 0:1/fs:duration-1/fs; % Time vector

% Generate synthetic EMG signal


emg_signal = 0.3 * sin(2*pi*50*t) + 0.1 * sin(2*pi*150*t); % Simulating muscle activity
emg_signal = emg_signal + 0.2 * randn(size(t)); % Adding noise

% Plot the EMG signal


figure;
plot(t, emg_signal);
title('EMG Signal');
xlabel('Time (s)');
ylabel('Amplitude');
OUTPUT:
RESULT:
Thus a Matlab program to generate EMG signals is written and executed successfully.

You might also like