Bio-Signal Processing Lab. Lec 1
Bio-Signal Processing Lab. Lec 1
https://matlab.mathworks.com/
Working with MATLAB
• To see list of variables on your workspace
– >> who % list variables
– >> whos % list all information
• Editor window(M-file): used to run and edit
commands /programs redundantly.
• MATLAB has built in functions which can be
used in Various computations.
– >>log(100), exp(a^2)
What is SIGNAL?
• Signal is a numerical quantity that can vary
with one or more independent variables.
• It carries information that helps to make a
useful decisions.
• Types of signal are continuous time signal and
discrete time signal.
• To demonstrate this in MATLAB we use:
– Plot(x,y)
– Stem(n,x)
Creating Simple Plots
Plot the following function in mat lab.
1. y=sin(x), 0<x<2pi
>> x=0:2*pi % defining domain
>>y= sin(x)
>>Plot(x,y)
Continuous-time Signal Example
% Generation of Sine % Generation of cosine
wave wave
t=0:0.1:10; t=0:0.1:10;
x=sin(2*pi*t); x=cos(2*pi*t);
plot(t,x); plot(t,x);
xlabel('Time'); xlabel('Time');
ylabel('Amplitude'); ylabel('Amplitude');
title('Sine wave'); title('Cosine wave');
Exponential Signal Example
%Real valued exponential sequence: a^n
n=-3:5
a1=0.8;
x1=a1.^n;
subplot(1,2,1);
plot(n,x1);
a2=1.2;
x2=a2.^n;
subplot(1,2,2);
plot(n,x2);
Exponential Signal Example
%Real valued exponential sequence a^n
n=-3:5
a1=0.8;
x1=a1.^n;
a2=1.2;
x2=a2.^n;
plot(n,x1,’:’,n,x2,’-’);
legend(‘x1’,’x2’);
Exercise 1
1. Plot the following functions in one figure and use
different colors.
• Annotations
A= sin(2x),0<x<Pi
– xlabel (‘ ‘)
B= cos(4*pi*x), 0<x<2*pi
Hint : – Ylabel (‘ ’)
plot(x, y, ‘color’, ‘shape’)
– title(‘ ’)
– legend(‘ ‘)
Exercise 2
2. % Plotting in 3-D space
x=0:.1:100;
y=cos(x);
z=sin(x);
plot3(x,y,z)
xlabel('x')
ylabel('y=cos(x)')
zlabel('z = sin(x)')
Discrete-time signals
% Generation of Impulse sequence
x=-2:1:2;
y=[0 0 1 0 0];
stem(x,y);
xlabel('Time');
ylabel('Amplitude');
title('Impulse sequence');
Home work
• Try the following MATLAB program and
write the interpretation of each.
report should include :
• Name, ID, Group, subgroup, school, course
title.
• Interpretation on comment section.
• Note: this homework is individual assignment
and holds 10 marks.
Home work 1
1. Plot the following functions in one figure and use
different colors. • Annotations
A= exp(x)+ sin(x)
– xlabel (‘ ‘)
Hint :
plot(x, y, ‘color’, ‘shape’) – Ylabel (‘ ’)
– title(‘ ’)
– legend(‘ ‘)
Homework 2
2. Generate a step sequence and plot the graph.
1, 𝑛𝑛 ≥ 0
𝑢𝑢 𝑛𝑛 = �
0, 𝑛𝑛 < 0
Ans
• X=stepseq(interval)
• y=[zeros(1,10) ones(1,11)];
• unit=n>=0;
Jimma Institute of Technology
School of Biomedical Engineering
Bio-signal Processing Lab.
Experiment 2