Professional Documents
Culture Documents
WHAT IS MATLAB?
MATLAB
Commercially available
Mathematical computational tool
Stands for Matrix Laboratory
Why MATLAB?
MATLAB gets two versions a year: an (a) version and a (b) version
MATLAB is updated regularly, and some functions are changed slightly
AUK students have free MATLAB access as long as they sign up for a
MathWorks account using their AUK emails
Interpreter Language
Window
Example
MATLAB Windows
Command
History Window
Records all commands
issued in the command
window – including
mistakes
IN CLASS DEMO
MATLAB interface.
Variables
Unlike Java or C, you do not need to declare the variable type when
creating a variable in MATLAB
Furthermore, MATLAB does not force you to end lines of code with a semi-
colon
A=3
Should be read as A is assigned a value of 3
Use the variables in subsequent calculations
Naming Variables
ans =
'break' 'global'
'case' 'if'
'catch' 'otherwise'
'classdef' 'parfor'
'continue' 'persistent'
'else' 'return‘
'elseif' ‘spmd’
'end‘ 'switch'
'for‘ 'try'
'function' 'while'
In Java, you called them “Methods”. But in MATLAB, they are called
functions
MATLAB functions are subroutines (that can be defined by the user or built
into MATLAB/MATLAB toolboxes)
We will learn many functions throughout this lab, and we will learn how to
write our own
Generally speaking, you should never name variables the same name as a
function!
This might “run”, but it is a bad habit and can cause logical errors
Which of these names are
allowed in MATLAB?
test
Test
if
x
my-book
x
my_book
Thisisoneverylongnamebutisitstillallowed?x
1stgroup
x
group_one
zzaAbc
z34wAwy?12#
sin x x
log bad
idea
Order of Operations
Command
Prompt
>> 9 + 10
ans=19
Result
IN CLASS DEMO