Matlab basics II Flashcards
.mat
special data format in matlab; default data file type
save
saves data from current matlab workspace to file
form: save(‘file_name’, ‘var1’, ‘var2’)
saves 1 or more variables: var1 and var2 in a file with the name file_name
default saves as .mat
can save in more general ascii format:
form: save(‘file_name.dat’, ‘var’, ‘-ascii’)
can also execute save in command form:
save file_name var1 var2
save file_name.dat var1 var2 -ascii
load
Loads data from a disk file to the current MATLAB workspace:
load(‘file_name’)
help
built in function; learn more about a specific function
doc
brings out the help browser window where a more complete help menu about the function will be displayed
log(x)
natural logarithm of x : lnx
log10(x)
log base 10 x
max(x), min(x)
find max, min values in the array x
sum(x)
vector: sum of elements
matrix: gives a row vector with sum over each column
sin(x)`vs sind(x)
gives sin of angle in radians vs. degrees
sin(x) vs asin(x)
sin(x) vs arcsin (x)
round(x)
rounds x to nearest integer
floor(x)
rounds x to nearest integer towards negative infinity
ceil(x)
rounds x to nearest integer towards positive infinity
fix(x)
rounds x to nearest integer towards 0
array operations
.* and ./
element-by-element (scalar) operations between two arrays of the SAME DIMENSION
a./b array right division, a/b
a.\b array left division. b/a
zeros
used to assign value of 0 to a variable or an element/bunch of elements in a variable
eye(n)
generates identity matrix of dimension (n,n)
ex. eye(3): 3x3 identity matrix
syntax error
spelling errors, punctuation errors, wrong shape/size/type of input, unbalanced brackets
“Undefined function or variable…”
“arguments dimensions are not consistent”
“expression or statement is incorrect”
Runtime error
found when function is executing
“exceeds matrix dimensions”
Logical/Algorithmic error
function executes without error but does not produce the desired result
debugging
set breakpoints to pause execution of matlab file; step through file
subarrays
selections of subsets of elements in original array
multidimensional array
can be created by putting lower dimension arrays together
multid_array(row_no,column_no,page_no,book_no,…)