Lesson 2 - Basics - MATLAB
Lesson 2 - Basics - MATLAB
Cheah
Topic 1 – MATLAB
Lesson 2 – Basics
1
Outline
Introduction
MATLAB Environment
MATLAB Basics
M-files (Script vs Function file)
Plotting
Flow Control & Loops
Graphical User Interface (GUI)
2
Outline
Introduction
MATLAB Environment
MATLAB Basics
M-files (Script vs Function file)
Plotting
Flow Control & Loops
Graphical User Interface (GUI)
3
Variables
Simple arithmetic computations are the easiest thing to do in MATLAB. For
example addition, multiplication, division, and powers are the standard
symbols.
If you look over at the workspace table in the top right of the page it will
have a variable ans with a value -4.0191e+05.
The variable ans always contains the result of the last computation.
4
Variables
5
Variables
6
Variables – Maths
7
Variables – Maths
8
Variables – Maths
9
Variables
10
Variables
11
Variables
12
Variables
13
Arrays
14
Arrays – Row & Column
row
column
row column
column
All rows
All columns
row
15
Arrays – Indexing
16
Arrays – Indexing
17
Arrays
merge or concatenate
18
Arrays – Colon
19
Arrays – Colon
20
Arrays
21
Arrays
22
Arrays
23
Arrays – Maths
24
Arrays – Maths
25
Arrays – Maths
26
Arrays – Linear Algebra
27
Arrays – Linear Algebra
We have a matrix multiplication equation of the form Ax = b, and we
want to solve for the unknowns x. This can be accomplished as
follows:
28
Arrays – Linear Algebra
29
Arrays – Linear Algebra
30