0% found this document useful (0 votes)
19 views7 pages

ELEC372 Lab1

Lab 1 of ELEC-372 introduces MATLAB as a tool for numerical methods and optimization, covering essential topics such as matrix operations, complex numbers, and plotting. Students are required to complete tasks in two sections, including writing MATLAB functions for decimal to binary conversion and demonstrating matrix multiplication properties. Each group must submit a report in a specified format, adhering to guidelines that prohibit the use of built-in MATLAB functions for course algorithms.

Uploaded by

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

ELEC372 Lab1

Lab 1 of ELEC-372 introduces MATLAB as a tool for numerical methods and optimization, covering essential topics such as matrix operations, complex numbers, and plotting. Students are required to complete tasks in two sections, including writing MATLAB functions for decimal to binary conversion and demonstrating matrix multiplication properties. Each group must submit a report in a specified format, adhering to guidelines that prohibit the use of built-in MATLAB functions for course algorithms.

Uploaded by

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

Lab 1

ELEC-372: Numerical Methods and Optimization


Instructor: Saeed Gazor
Lab#1: Overview of MATLAB

MATLAB represents an interpreted array programming language as well as a vast collection of


engineering software tools and graphical interfaces used for the analysis, design and simulation
of systems. MATLAB is used in a growing number of disciplines related to Electrical and
Computer Engineering. It is used not only in Numerical Methods and Optimization (ELEC-372)
but also to support other course sequences in Signals and Systems (ELEC-323/324), Signal
Processing (ELEC-421/422), Communications at the physical layer (ELEC-461/464) as well as
Control and Robotic systems (ELEC-443/448). Other technical elective courses may use
MATLAB to some extent. The objective of MATLAB Labs is to offer concentrated practice and
experience in MATLAB. It is assumed that students do not have prior exposure to MATLAB but
are generally familiar with elementary linear algebra and procedural programming in a higher-
level language. Being offered inside a numerical method & optimization course, a secondary
objective is to provide MATLAB-based examples that illustrate concepts related to the outlines
of numerical methods and basic optimization techniques.

 Lab#1: Introduction of MATLAB (Self-directed tour under TA’s supervision)


The lab session covers the topic areas discussed in Lecture Notes (LN#2) such as MATLAB
expressions, Iteration, Scalar, Vector and Matrix operations, Complex numbers, Loops, Plots, and
writing .m file MATLAB programs.

Note: The Lab#1 has 2 sections containing 5 parts in total. The (expected) required time for each
part is highlighted (you may manage your time for providing & submitting your report).

Each group needs to submit one [see the example bellow].pdf report as the following format:
Group name (based on 4 members):
1- Your first name, Your last name, Your student id
2- Your first name, Your last name, Your student id
3- Your first name, your last name, Your student id
4- Your first name, your last name, Your student id

1
Lab 1

The script of the code +


input and output (the screenshot for this is enough!)

DO NOT USE THE BUILT-IN FUNCTIONS in MATLAB for implementing the


Methods/Algorithms for this COURSE!

The file name for submission must be as the following format:


“Lab1_ [The first letters of your name and family names]”

Example:
Lab#1
1- Alice, Spring, 12345678
2- Bob, Winter, 01234567
3- Joe, Fall, 98765432

Name of the .pdf file for the submission would be: Lab1_ASBWJF.pdf

 Tasks

Section 1) From LN#2: [expected time: 30 min]


- Display (e.g., page 12)
- Iteration (make the Golden number with various initialization, e.g., -10. – 3.555, -
0.00001, 0.000001, 0.5, 1, 1000) (e.g., pages 18 & 24 & 41) and plot the progress of
the values versus iteration number, e.g., 100)
- Complex numbers and roots finding (e.g., page 49 & 52)
- Apply more functions over a given scalar, vector, and matrix (e.g., page 62)
- Plot (e.g., pages 98~100)

2
Lab 1

Section 2)

1) Illustrate the associative law of multiplication of matrices using


1 2 
 2 5  2 1
[ A]  3 5, [ B]    , [C ]  
 9 6  3 5
0 2
i.e., ([A][B])[C] = [A]([B][C])

Repeat it with random matrices (e.g., rand(), randn() etc) with various dimensions.

[expected time: 15 min]

3
Lab 1

4
Lab 1

2) Write a MATLAB function named “decTObin” that implement (design, write, debug)
the algorithm of decimal to Binary mentioned in LN#1 as follows: [expected time: 30
min]

Start

Integer N to be converted to
Input (N)10
binary format

i=0

Divide N by 2 to get quotient Q


& remainder R

i=i+1,N=Q
ai = R

No
Is Q = 0?

Yes

n=i
(N)10 = (an. . .a0)2

STOP

5
Lab 1

3) Write a MATLAB function named “FracDec2Bin” that implements (design, write,


debug) the algorithm of fractional decimal to Binary mentioned in LN#1 as follows:
[expected time: 30 min]

Start

Fraction F to be converted to
Input (F)10
binary format

i = −1

Multiply F by 2 to get number


before decimal, S and after
decimal, T

i = i − 1, F = 𝑇

ai = R

No
Is T =0?

Yes

n=i
(F)10 = (a-1. . .a-n)2

STOP

6
Lab 1

4) Write a MATLAB function named “SP_format” to take a decimal value as an input


and convert it to the single precision IEEE-754 format.

Then, write another MATLAB function named “DP_format” to take a decimal value
as an input and convert it to the double precision IEEE-754 format.

[expected time: 75 min]

You might also like