Built-in Functions Flashcards
help [insert word here]
Explains word.
Ex. Help, format, elfun, etc.
Demo
Shows MATLAB examples in help window
doc
Shows documentation page in help window
Quit
Exit
Close MATLAB
namelengthmax
63
who
Shows variables in command window
whos
Shows variables and information in command window
clear
Deletes variables
intmin (‘int8’)
intmax (‘int8’)
-128
127
intmin (‘int16’)
intmax (‘int16’)
Help!
intmin (‘int32’)
intmax (‘int32’)
Help!
format short
Answer in four decimal places
format long
Answer in 15 decimal places
Format loose
Double spaced
Format compact
Single spaced
fix (x)
Rounds towards zero
floor (x)
Rounds towards negative infinity
ceil
Rounds toward positive infinity
rem (x, y)
Returns remainder of x/y
mod (x, y)
Returns remainder of x/y. Mod (x, 0) returns x.
Sign (x)
Returns 1 or -1 depending on sign of x.
nthroot (x, y)
Returns the y- root of x.
exp (n)
Returns e^n
rand
Returns random number between 0 and 1
rng (‘shuffle’)
Sets seed to clock time
rng (‘intseed’)
Sets seed to an integer
rng (‘default’)
Sets seed to default number determined by MATLAB startup.
rand*10
Random number between 0 and 10
rand *(high - low) + low
Generates a random number between high and low.
round (rand)
Rounds the random real number produced by rand to an integer.
randi ([intmin, intmax])
Generates random integer between intmin and intmax.
length (vec)
Returns number of elements in vector.
length (mat)
Returns number of rows or columns, whichever is larger
size (vec)
size (mat)
Returns the number of rows and columns
Hint:
[r c] = size (mat)
numel (vec)
numel (mat)
Returns number of elements.
fliplr (mat)
flipud (mat)
rot90 (mat)
reshape (mat)
Ways to alter a matrix
vec = [ ]
Creates an empty vector
vec (x) = [ ]
Deletes the x-th element
Note: individual elements cannot be removed from matrices. Must remove an entire roe or column.
mat ( : , x) = [ ]
diff(vec)
Returns the difference between elements in vec. Length will be 1 less than length of vec.