Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
15 views

Lab 1 - Introduction To MATLAB 2023 - 24

1. This document provides instructions for a MATLAB lab introduction exercise with 4 tasks: basic MATLAB commands, plotting graphs, convolution, and generating sinusoidal signals. 2. Task 1 introduces basic MATLAB commands and functions through interactive examples. Task 2 demonstrates plotting graphs using the plot and stem functions. 3. Task 3 explains convolution and provides an example calculation and graph. Task 4 generates a sinusoidal signal with variables for amplitude, frequency, and phase to plot continuous and discrete signals. 4. The document includes spaces to record experiment data and results from the tasks. Questions at the end test understanding of sinusoidal signal parameters and generation.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Lab 1 - Introduction To MATLAB 2023 - 24

1. This document provides instructions for a MATLAB lab introduction exercise with 4 tasks: basic MATLAB commands, plotting graphs, convolution, and generating sinusoidal signals. 2. Task 1 introduces basic MATLAB commands and functions through interactive examples. Task 2 demonstrates plotting graphs using the plot and stem functions. 3. Task 3 explains convolution and provides an example calculation and graph. Task 4 generates a sinusoidal signal with variables for amplitude, frequency, and phase to plot continuous and discrete signals. 4. The document includes spaces to record experiment data and results from the tasks. Questions at the end test understanding of sinusoidal signal parameters and generation.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 17

FAKULTI TEKNOLOGI DAN KEJURUTERAAN

ELEKTRONIK DAN KOMPUTER


UNIVERSITI TEKNIKAL MALAYSIA MELAKA

SIGNAL & SYSTEMS

BERT 2423 SEMESTER 1 SESSION 2023/2024

LAB 1: INTRODUCTION TO MATLAB

1.

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

3.

COURSE 2 BEEC

DATE

TS. DR. NOR AZLAN BIN MOHD ARIS


NAME OF INSTRUCTOR(S)

EXAMINER’S COMMENT(S) VERIFICATION STAMP

TOTAL MARKS
FTKEK/JTK/BERT2423

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

Page 3 of 17
FTKEK/JTK/BERT2423

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.)

Page 4 of 17
FTKEK/JTK/BERT2423

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

Page 5 of 17
FTKEK/JTK/BERT2423

Task 3: Convolution

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


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

a = [1 2 3];
b = [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.)

Page 6 of 17
FTKEK/JTK/BERT2423

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

Page 7 of 17
FTKEK/JTK/BERT2423

5.0 EXPERIMENT DATA

From Task 1: Basic MATLAB®

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

ans =

From Task 3: Convolution

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

ans =

Page 8 of 17
FTKEK/JTK/BERT2423

6.0 EXPERIMENT RESULTS

From Task 2: Plotting Graph

Page 9 of 17
FTKEK/JTK/BERT2423

Graph 1: Plotting the graph

Page 10 of 17
FTKEK/JTK/BERT2423

From Task 3: Convolution

Page 11 of 17
FTKEK/JTK/BERT2423

Graph 2: Convolution Plotting

Page 12 of 17
FTKEK/JTK/BERT2423

From Task 4: Generate Sinusoidal Signal

Page 13 of 17
FTKEK/JTK/BERT2423

Graph 3: Sinusoidal Signal Plotting

Page 14 of 17
FTKEK/JTK/BERT2423

7.0 QUESTIONS & DISCUSSION

1. Use MATLAB, evaluate the expression 2a3 +√bd −5c , where a=1.5, b=2, c=4.5 and
d=5.

2. Use MATLAB, calculate the convolution below.


X[n] = [5 -3 6 9]
Y[n] = [10 -15 3 6]

3. From Task 4, answer the questions below.

(a) Which command line controls the frequency in this program?

(b) Which parameter controls the phase of this sequence?

(c) Which parameter controls the amplitude of the sequence?

(d) What is the frequency of this sequence?

Page 15 of 17
FTKEK/JTK/BERT2423

4. Write a programming using this expression:

X(n) = 2 sin (2*pi*f*n + ), 0 < n < 50,  = 0, f=0.1

What is the different the graph obtained from this programming compare to
the Graph 3 (obtained from Task 4)?
(Attached the programming and graph obtained at different sheet.)

Page 16 of 17
FTKEK/JTK/BERT2423

8.0 CONCLUSION

Page 17 of 17

You might also like