You are on page 1of 14

www.covenantuniversity.edu.

ng

Raising a new Generation of Leaders

EIE 325
USE OF ENGINEERING
PACKAGES
GETTING STARTED WITH MATLAB
Lecturers: Mrs Temitope Takpor & Mrs Mercy Kayode
2
Getting Started with MATLAB
• When you start MATLAB®, the desktop appears in its default layout

3
.

Getting Started with MATLAB - Desktop


• The desktop includes these panels:
• Current Folder — Access your files.
• Command Window — Enter commands at the command line,
indicated by the prompt (>>).
• Workspace — Explore data that you create or import from files. It
shows all the variables you have defined in your current session.
Variables can actually be manipulated within the workspace window.

4
.

MATLAB Desktop
• As you work in MATLAB, you issue commands that create variables
and call functions. For example, create a variable named a by typing
this statement at the command line:
a=1
• MATLAB adds variable a to the workspace and displays the result in
the Command Window.
a=

5
.

MATLAB Desktop
• Create a few more variables
b=1
b=

c=a+b
c=

6
.

Getting Started with MATLAB


• Create a few more variables
b=1
b=

c=a+b
c=

7
.

MATLAB Desktop
d = cos (a)
d=

0.5403

• When you do not specify an output variable, MATLAB uses the variable ans, short
for answer, to store the results of your calculation.
sin (a)
ans =

0.8415

8
.

MATLAB Desktop
• If you end a statement with a semicolon, MATLAB performs the
computation, but suppresses the display of output in the Command
Window.
e = a*b;
• You can recall previous commands by pressing the up- and down-
arrow keys, ↑ and ↓. Press the arrow keys either at an empty command
line or after you type the first few characters of a command. For
example, to recall the command b = 2, type b, and then press the up-
arrow key.

9
.

MATLAB Basic Arithmetic Operations


• Addition (+), Subtraction (-), Multiplication (*), Division (/), Power (^)
• Order of Operations (same rules you should already know from math
class and using a calculator).
• Complete all calculations inside parenthesis or brackets using the
precedent rules. BODMAS rule (brackets, order, division, multiplication,
addition, subtraction).

10
.

MATLAB Basic Arithmetic Operations


▪ Some examples:

>> 20/4*2

>> 4*3^2+4*(2)

>> -1^4

>> 8^1/3
11
.

MATLAB Basic Arithmetic Operations

12
.

MATLAB Basic Arithmetic Operations


• Note the multiplication * operator before the brackets
>> 4*3^2+4*(2)

13
.

MATLAB Basic Arithmetic Operations


• Exercise:

• Calculate the area and circumference of a circle with a radius of 6 cm


in MATLAB.

14

You might also like