fixed point with 4 decimal digits within the range of 0.001 to 1000
format long:
fixed point with 15 decimal digits with the range of 0.001 to 1000
format short e:
Scientific notation with 4 decimal digits
format long e:
Scientific notation with 15 decimal digits
format short g:
best of 5 digit fixed or floating point
format long g:
Best of 15 digit fixed or floating point
format bank:
2 decimal digits (good for analysis that involves currency)
format compact:
removes extra blank lines
sqrt(x):
function that returns the square root of x
exp(x):
returns the exponential of x
abs(x):
returns the absolute value of x
log(x):
returns the natural log of x
sin(x):
returns the sine of angle x (x is in radians)
sind(x):
returns the sine of angle x (x is in degrees)
asin(x):
returns the inverse sine (arcsin) in radians of value x
asind(x):
returns the inverse sine (arcsin) in degrees of value x
function of "=" in MATLAB
assigns a new value to a variable
only type of character a variable may begin with
letter
maximum length of a variable name in MATLAB
63 characters
types of characters a variable name may contain
letters, numbers, and the underscore character
"clear" command
removes all variables from memory
"clear var1 var2" command
removes the specific variables var1 and var2 from memory
exist ('name') command
determines if a file or a variable exists with the name 'name'
"quit" or "exit" command
stops MATLAB
[space key]
ignored in equations by MATLAB
"who" command
lists the variables in current memory
"whos" command
lists the current variables and sizes, and indicates if they have imaginary parts
Ctrl+C, Ctrl+Break commands
stops execution of a program
"up arrow" commands
up arrow at the command prompt recalls previous command
"Iskeyword" command
Lists all keywords used in MATLAB
"ans"
most recent answer; this will be overwritten every time something is evaluated but not assigned to a variable
"eps"
specifies accuracy of floating point precision
"i" or "j"
may be used for the imaginary value "square root of -1"
Inf
infinity
NaN
stands for "Not a Number"; indicates an undefined numerical result
pi
The value of pi
Ctrl+C, Ctrl+Break commands
can be used to unfreeze MATLAB if it locks up
m-file
script/computer program made by MATLAB
character an m-file must begin with
letter
maximum length of an m-file name in MATLAB
63 characters
types of characters an m-file name can contain
letters, numbers, and the underscore character
type of character an m-file name cannot contain
space
character string the m-file section headings start with
%%"space character"
how to run an entire m-script file
click on the "run" icon in the ribbon when the Editor tab is selected
how to run a particular section of an m-script file
click on any code in that section to highlight the section, then click on "run section"
simple array
One-dimensional array; a number list in a row or column; vector
two-dimensional array
numbers in rows and columns; matrix
characters used to define arrays
Square brackets ("[]")
term that determines the starting number in a one-dimensional vector
first term in the vector
term that determines the spacing in a one-dimensional vector
middle term in the vector
term that determines the ending point in a one-dimensional vector
third and final term in the vector
assumed spacing if only two terms are entered in a one dimensional vector
1
command used to call out the kth element in a row or column vector
variable_name (k)
command used to called out the mth-nth elements in a row or column vector
variable_name(m:n)
command used to call out the entire row or column vector
variable_name(:)
command used to call out the element in row "K" and column "P" of a matrix
variable_name (K, P)
command used to call out the elements in column "n" of a matrix
variable_name(:, n)
command used to call out the elements in row "n" of a matrix
variable_name(n,:)
mean (A) function for arrays
returns the mean or average value of the elements in vector A
max (A) function for arrays
returns the largest value of the elements in vector A
min (A) function for arrays
returns the smallest value of the elements in vector A
[d,n]= max(A) function for arrays
returns the largest value of the elements (d) and the position of the element (n) in vector A
[d,n]=min(A) function for arrays
returns the smallest value of the elements (d) and the position of the element (n) in vector A
sum (A) function for arrays
returns the sum of the elements in vector A
sort (A) function for arrays
arranges the elements in vector A in ascending order
how to display an output
type the variable and press "enter"; use one of the disp commands: disp(variable_ name) or disp('string') or disp(' '); use one of the fprint commands: fprintf('string') or fprint('text %f more text', variable_name)