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

Signals & Systems Lab Overview

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)
16 views22 pages

Signals & Systems Lab Overview

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

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 [Link]
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.

Common questions

Powered by AI

In MATLAB, signal processing capability facilitates the analysis of both discrete and continuous time signals through a series of operations such as generation, plotting, and transformation of signals. For discrete time signals, operations include generating sinusoidal, cosine, square, sawtooth, and exponential signals using functions like 'stem' to plot these on a graph . Continuous time signals are similarly generated and plotted using functions like 'plot' for sine, cosine, square, and sawtooth waves . Additionally, MATLAB allows for operations like convolution (e.g., convolution of sequences), stability checking of systems (e.g., by computing poles and zeros), and verification of concepts such as the sampling theorem, which involves converting continuous signals into discrete time signals by sampling theory . These tools enable comprehensive analysis and visualization of both signal types in technical and research settings.

The primary differences between generating discrete versus continuous signals in MATLAB lie in the methods of signal representation and plotting. Discrete signals are generated using a restricted set of points across the time axis, which are typically plotted using the 'stem' function, indicating individual samples at specific instances with a finite amplitude at each sample . Continuous signals, on the other hand, are represented by defining a time vector with small time intervals and are plotted using the 'plot' function, which creates a continuous line representing the signal's behavior over a continuous period . Additionally, when generating discrete signals, operations focus on sample-by-sample computations, whereas continuous signals involve computing signal properties over a duration. These methodologies reflect the conceptual differences between the two signal classes, crucial for appropriate applications in engineering and scientific analyses.

The process of convolution of two discrete signals in MATLAB involves using the 'conv' function, which computes the convolution of two sequences. In the document, discrete sequences x(n)=[1,2,-1,3] and h(n)=[2,-1,1,4] are convolved, and the resulting sequence y(n)=x(n)*h(n) is plotted to show the outcome . Convolution is significant because it allows the determination of the output (y(n)) when an input signal (x(n)) passes through a linear time-invariant (LTI) system characterized by its impulse response (h(n)). This process is fundamental in signal processing, mimicking the effects of an LTI system, and is used widely in areas such as audio signal processing, and communications .

The document recommends checking the stability of discrete and continuous time systems in MATLAB using transfer functions. For discrete systems, this involves obtaining the coefficients of numerator and denominator polynomials, computing the transfer function, and calculating the poles and zeros. Stability is determined through a pole-zero plot, checking the pole locations, with inner circle poles indicating stability . For continuous systems, a similar approach is taken but involves modeling the system using a zero-pole-gain configuration and again evaluating pole positions. If poles lie within the left-hand plane for continuous, or inside the unit circle for discrete systems, the system is stable . These techniques are vital for ensuring control systems function correctly without undesired oscillations or behaviors.

The process of generating continuous time sinusoidal signals using MATLAB involves several key steps and parameters. First, define a time vector 't' covering the desired time range with sufficient resolution. Then, set the frequency 'f' of the sinusoidal signal. The signal 'y' is then computed using the formula y=sin(2*pi*f*t) or y=cos(2*pi*f*t), depending on whether a sine or cosine wave is desired. This signal can be plotted using 'plot' to visualize the wave over time. This setup allows for easy analysis and manipulation of continuous signals for various applications . These parameters and steps help in accurate signal representation and fidelity in simulation analyses.

The document describes MATLAB's capability in visualizing data through its 2D and 3D graphics functions which enable the creation of detailed plots and modeling visuals. These functions allow users to explore and interpret complex data structures efficiently. Additionally, MATLAB provides tools for building custom user interfaces (GUIs), which can facilitate interactive problem-solving environments tailored to specific needs or applications. These GUI tools help manage codes and data files, enhancing user engagement and usability of MATLAB applications, making it suitable for various engineering and scientific tasks requiring tailored data visual representations and user controls .

The methodology for verifying the sampling theorem in MATLAB involves generating a continuous time signal and converting it to a discrete time signal through sampling. The document outlines plotting an arbitrary continuous signal, converting it using the sampling theorem, and examining the effects of aliasing and Nyquist rate. The process includes defining a continuous cosine signal and using different sampling frequencies to show effects like aliasing when the sampling rate is too low. The Nyquist effect is shown by setting the sampling frequency fs slightly above twice the maximum frequency of the continuous signal (fs > 2fmax). This demonstrates the requirement for the sampling rate to be twice the maximum frequency of the signal to avoid aliasing and ensure accurate reconstruction of the original signal.

MATLAB is described as a high-level language for technical computing development with several key features. It includes an interactive integrated environment for managing code, files, and data, and interactive tools for design and problem solving. It supports mathematical functions for linear algebra, statistical Fourier analysis, filtering, optimization, and numerical integration, and has 2D and 3D graphics functions for visualizing data. These features contribute to MATLAB's functionality by streamlining the development process, allowing for efficient computation and visualization, reducing administrative tasks, and enabling the creation of custom user interfaces, thus enhancing technical computing tasks .

MATLAB's built-in functions and plotting capabilities play crucial roles in facilitating program development, especially in signal analysis. Built-in functions such as sin, cos, exp, conv, and tf allow for complex mathematical operations without the need for implementing underlying algorithms from scratch. Plotting capabilities, including commands like plot and stem, aid visualization by quickly generating graphs of data and signal characteristics, such as waveforms of continuous and discrete signals. These tools help developers perform numerical and symbolic calculations, visualize data for better insight, and debug code efficiently, thus accelerating development cycles and enhancing analysis precision for projects related to technical computing and engineering .

MATLAB handles the generation and manipulation of biosignals such as EMG (Electromyography) signals through coding that simulates muscle activity and processes noise. The document provides an example where a synthetic EMG signal is generated using a combination of sinusoidal functions to simulate the signal and random noise to imitate real world variations. A sampling frequency, time vector, and sine functions are used along with additive white Gaussian noise to simulate EMG signals realistically. The code then plots the signal for analysis . This allows biomedical engineers to analyze and process biosignals within MATLAB, providing a platform for developing biomedical applications.

You might also like