Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

FAKULTI TEKNOLOGI KEJURUTERAAN

ELEKTRIK DAN ELEKTRONIK


UNIVERSITI TEKNIKAL MALAYSIA MELAKA

SIGNAL & SYSTEMS

BEET 2423 SEMESTER 1 SESSION 2022/2023

LAB 1: INTRODUCTION TO MATLAB

1.

NAME OF GROUP
MEMBER(S) & 2.
MATRIX NUMBER(S)

3.

COURSE BEEZ

DATE

TS ZAHARIAH BINTI MANAP


NAME OF INSTRUCTOR(S)
TS MOHD ERDI BIN AYOB

EXAMINER’S COMMENT(S) VERIFICATION STAMP

TOTAL MARKS
1.0 OBJECTIVES

1. Able to understand the basic concept of MATLAB®

2. Able to use MATLAB® for plotting graph

3. Able to use MATLAB® for convolution

4. Able to use MATLAB® to generate sinusoidal signal

2.0 EQUIPMENT

1. MATLAB® software.

3.0 SYNOPSIS & THEORY

What is MATLAB®
MATLAB® is a high-level programming language that has been used extensively to solve

complex engineering problems. MATLAB® works with three types of windows which are
Command window, the Figure window and the Editor window. The Figure window only
pops up whenever you plot something. The Editor window is used for writing and editing

MATLAB® programs (called M-files) and can be invoked in Windows from the pull-down
menu after selecting File | New | M-file. The Command window is the main window in

which you communicate with the MATLAB® interpreter. The MATLAB® interpreter displays
a command “>>” which indicating that it is ready to accept commands from you.

The MATLAB® is usually use for technical computing integrates computation, visualization,
and programming in an easy-to-use environment where problems and solutions are
expressed in familiar mathematical notation. Typical uses include:

(i) Math and computation


(ii) Algorithm development
(iii) Data acquisition
(iv) Modelling, simulation, and prototyping
(v) Data analysis, exploration, and visualization
(vi) Scientific and engineering graphics
(vii) Application development, including graphical user interface building
4.0 PROCEDURE

1. From the Task 1-4 below, run all tasks using MATLAB®.

Task 1: Basic MATLAB®

1. View the MATLAB® introduction by typing

>> intro

at the MATLAB prompt. This short introduction will demonstrate some basic MATLAB
commands.

2. Explore MATLAB’s help capability by trying the following:

>> help
>> help plot
>> help ops
>> help arith

3. Type demo and explore some of the demos of MATLAB commands.

4. Evaluate the expression a3 +√bd −4c , where a=1.2, b=2.3, c=4.5 and d=4.
Then in the Command window, type:

a=1.2;
b=2.3;
c=4.5;
d=4;
a^3+sqrt(b*d)-4*c

ans = ? (Write down the answer at Experiment Data)

(Note: Put the semicolon after each variable assignment. If you omit the semicolon,
then MATLAB echoes back on the screen the variable value.)
Task 2: Plotting Graph

1. The function plot is used to generate line plots. The function stem is used to generate
“picket-fence” type of plots.

2. Type:

x=1:20;
plot(x) % see Figure 1
stem(x) % see Figure 2

Figure 1: Plot obtained using the plot function Figure 2: Plot obtained using the stem function

3. Type the program below and plot the graph obtained at Experiment Result. (Graph 1)

x=1:40;
subplot (2,1,1), plot(x)
subplot (2,1,2), stem(x) % see Graph 1
Task 3: Convolution

1. The convolution in MATLAB is accomplished by using conv command.


2. Consider the polynomials a(s) = 3s3+2s2+4s+3 and b(s)=4s3+4s2+5s+6.
To calculate their product, type:

a = [3 2 4 3];
b = [4 4 5 6];
conv(a,b)

ans = ? (Write down the answer at Experiment Data)

3. Type the program below and plot the graph obtained at Experiment Result. (Graph 2)

x =[0 1 1 1 1 1 1 1 1 1 1 1 1 1];
h = [1 0.5 0.25 0.125 0.0625];
y = conv(x,h);
nz = 10;
ly = length(y) + nz;
xz = [x, zeros(1,ly-length(x))];
hz = [h, zeros(1,ly-length(h))];
yz = [y, zeros(1,nz)];
nn = 0:ly-1;
subplot(3,1,1),stem(nn,xz,'filled'),axis([0 25 0 2]),
ylabel('x(nT)'), grid on
subplot(3,1,2),stem(nn,hz,'filled'),axis([0 25 0 2]),
ylabel('h(nT)'), grid on
subplot(3,1,3),stem(nn,yz,'filled'),axis([0 25 0 3]),
xlabel('Sample Index - n')
ylabel('y(nT)'), grid on % see Graph 2

(Note: Variables (array) x represents the input, y is the output, and h is the system.)
Task 4: Generate Sinusoidal Signal

1. A sinusoidal signal can be either sine or cosine time signal and it can be
expressed by:

X(n) = A sin (n + ), - < n < 

Where  = 2*pi*f

Therefore:
X(n) = A sin (2*pi*f*n + ), - < n < 

Similarly, sinusoidal signal for a cosine function can be expressed as:

X(n) = A cos (2*pi*f*n + ), - < n < 

Where n = integer variable called the sampler number


A = Amplitude of the sinusoid
 = frequency in radian per sample
 = phase in radians

2. Type the program below and plot the graph obtained at Experiment Result. (Graph 3).

n=0:40;
f=0.1;
P=0;
A=1;
arg=2*pi*f*n+P;
x=A*cos(arg);
clf; %clear and graph
subplot (2,1,1), plot (n,x), axis([0 40 -2 2]),
xlabel('Time index n'), ylabel ('Amplitude'),
title('Continuous Sinusoidal Signal'), grid on
subplot (2,1,2), stem (n,x), axis([0 40 -2 2]),
xlabel('Time index n'), ylabel ('Amplitude'),
title('Discrete Sinusoidal Signal'), grid on % see Graph 3

You might also like