Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

University of Sharjah College of Engineering

University of Sharjah
Electrical Engineering Department
Introduction to EEE -0402100

Lab-6: MATLAB Importing, Indexing and Flow Control


OBJECTIVES:

1. Study how to import data into MATLAB.


2. Learn how to use indexing in MATLAB to access certain data.
3. Learn how to control the flow of your code in MATLAB.

INTRODUCTION:

MATLAB allows you to import different type of data including tables, spreadsheets, images and
sounds. Once imported into MATLAB, you can determine their size and deal with them in the form
of matrices and vectors. Indexing allows you to access a specific element(s) in a vector or a matrix
and either display or modify their values. Conditional statements enable you to select at run time,
which block of code to execute. Moreover, if statement can be followed by an optional else statement,
which executes when the expression is false.

PROCEDURE:

Click on the following link, which will guide you to the MathWorks portal for the University of
Sharjah:
https://www.mathworks.com/academia/tah-portal/university-of-sharjah-31476961.html

1. Select the option “Learn MATLAB”, which is shown in Figure-1 below.

Figure 1
University of Sharjah College of Engineering

2. Select the option “Start learning now”, which is shown in Figure-2 below.

Figure 2

3. Sign in to your account created during lab-4 using your university email address and password as
shown in Figure-3 below

Figure 3

4. Resume the MATLAB Onramp course as shown in Figure-4 below.

Figure 4
University of Sharjah College of Engineering

5. You are supposed to complete chapter 11 to 15 in this session as shown in Figure-5 below.

Figure 5

6. After the completion of assigned chapters, you are supposed to submit the assignment given below
individually through the Blackboard. Screenshot/Save all your results and submit it as a softcopy.

You may also refer to the following videos for more information on (optional):

I Functions Input/Output:
https://www.youtube.com/watch?v=47YrEouBB8M&list=PLgEkkJcwLzjeL2Ywe0g66GaggDQxmV05p&index=15

Formal Definition of Functions on MATLAB:


: https://www.youtube.com/watch?v=OwHx_EtAs1k&list=PLgEkkJcwLzjeL2Ywe0g66GaggDQxmV05p&index=16

ASSIGNMENT:

1. Write brief function script to evaluate the following:

ℎ(𝑇𝑇) = 𝑇𝑇 − 12 𝑤𝑤ℎ𝑒𝑒𝑒𝑒 0 < 𝑇𝑇 < 100


= 0.25 𝑇𝑇 + 400 𝑤𝑤ℎ𝑒𝑒𝑒𝑒 𝑇𝑇 > 100

Test cases:
a. T = 89 (h must be returned as 77)
b. T = 121 (h must be returned as 430.25)

2. Create a 1x9 (1 row, 9 columns) vector of random numbers (use randn command “x = randn(1,9)). And
do the following:

a. Test vector x for elements that are less than 0.4. Assign the output to a variable named y.
b. Create a variable A that contains the elements in x that are greater than 0.4.
c. Modify vector x such that any value in it less than 0.4 is replaced by value 0.

You might also like