Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
variablename = expression |
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
initializing (a variable) |
|
Definition
Putting the first or initial value in a variable |
|
|
Term
|
Definition
adding to a variable
ex. mynum= mynum+1 increments by 1 |
|
|
Term
|
Definition
subtracting from a variable
ex. num = num-1 decrements by 1 |
|
|
Term
|
Definition
ex. variable names
rules:
must begin with letter
can have letters, digits, and _ (underscore)
no spaces
limit to length (namelengthmax to find)
case-sensitive (Num_1 =/= num_1)
cannot be a reserved word
*should* not be name of built-in function |
|
|
Term
|
Definition
shows variables that have been defined in this Command Window (only shows variable names)
>>who
Your variables are:
ans mynum variablename |
|
|
Term
|
Definition
shows more information on variables defined in Command Window
shows name, size, bytes, class, attributes |
|
|
Term
|
Definition
clears out all variables so they no longer exist |
|
|
Term
|
Definition
clears out the variable variablename |
|
|
Term
|
Definition
a combination of values, variables that have already been created, operators, built-in functions, and parentheses that can be computed by Matlab and output a value |
|
|
Term
|
Definition
displays 4 decimal places |
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
...
used for long expressions that continue on the next line
ex.
3 + 5 - 62 + 4 - 5 ...
+ 22 - 1
ans=
16 |
|
|
Term
|
Definition
operates on a single value
ex.
"-"
-7
negative |
|
|
Term
|
Definition
value that an operator operates on
ex.
7 and 2 in
7*2 |
|
|
Term
|
Definition
operates on 2 values
ex.
+
-
*
/ divided by
\ divided into
^ exponentiation |
|
|
Term
|
Definition
priority in order of operations
parenthesis can change precedence
highest->lowest precedence:
()
^
- (negation)
*, /, \
+, - |
|
|
Term
|
Definition
in the same precedence level, operations are performed from left to right |
|
|
Term
|
Definition
inner parentheses evaluated first
ex.
3*((4^2)+7) |
|
|
Term
|
Definition
lists and describes built-in elementary functions
broken into trigonometric (for which the default is radians), exponential, complex, and rounding and remainder functions |
|
|
Term
|
Definition
lists and describes operators |
|
|
Term
|
Definition
value that function is applied to
ex.
abs(-4)
calls the function abs
returns 4 |
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
|
|
Term
|
Definition
returns either 1 or -1 or 0
indicates positive, negative or 0 |
|
|
Term
|
Definition
matlab stores
pi 3.14...
i sqrt(1)
j sqrt(1)
inf infinity
NaN (0/0)
|
|
|
Term
|
Definition
e is not stored as constant
e=exp(1)
=2.7183 |
|
|
Term
|
Definition
for a variable or expression |
|
|
Term
|
Definition
default
for "double precision"
larger numbers than single |
|
|
Term
|
Definition
int8 - 8 bits to store the integer and its sign (-128 to 127)
int16
int32
int64
to find the range for each, use intmin('int32') and intmax('int32')
using the smallest type saves space
if you go beyond the range of a type, it will use its max instead
int8(200) = 127 |
|
|
Term
|
Definition
stores single characters (eg 'x')
or
strings, sequences of characters (eg 'cat')
enclosed in ' ' |
|
|
Term
|
Definition
|
|
Term
|
Definition
changing a value to a different type
use name of type changed to as fuction
ex.
change num from double to int32
num=int32(num)
|
|
|
Term
|
Definition
pseudo-random, start with seed that is predetermined or assigned by a clock in the computer
the seed is the same every time Matlab is opened, unless that state is changed
rand('state',sum(100*clock)) |
|
|
Term
|
Definition
generates a random number between 0 and 1
with 4 decimal places
>>rand
ans=
.2311
rand*n will generate a random number from 0 to n
rand*7
to generate a random number from low to high
low=4;
high=5;
rand*(high-low)+low |
|
|
Term
|
Definition
>> randint(1,1,n) generates one random integer in the range from 0 to n-1
(default type double)
>> randint(1,1,[1,20])
generates a random integer between 1 and 20 |
|
|
Term
|
Definition
includes all letters of the alphabet, digits, punctuation marks, and more; all the keys on a keyboard
given integer values
use ' ' for characters |
|
|
Term
|
Definition
American Standard Code for Information Interchange
128 characters
integer values from 0 to 127 |
|
|
Term
|
Definition
converts from number type to char type
ex.
char(97)
ans=
a |
|
|
Term
|
Definition
sequence of characters
ex.
'abcd'
double('abcd')
ans=
97 98 99 100
char('abcd'+1)
ans=
bcde |
|
|
Term
|
Definition
dimensions r x c (r by c)
2d array
mat=[1 2 3; 4 5 6]
or
mat=[1:3; 4:6]
rand(r) creates a rxr matrix of random values between 0 and 1
rand(r,c) creates a r x c matrix of random numbers between 0 and 1
>> randint(2,4,[10,30]) creates a 2x4 matrix with random values in [10, 30]
zeroes(r,c) creates an r x c matrix of zeroes |
|
|
Term
|
Definition
1xn or nx1
row or column vector
row: v=[1 2 3 4] or v=[1,2,3,4] or v=1:5
column: v' or [1;2;3;4]
subset of matrix
one dimensional array |
|
|
Term
|
Definition
|
|
Term
|
Definition
values stored in matricies |
|
|
Term
|
Definition
|
|
Term
|
Definition
first:step:last
nv=1:2:9
nv=
1 3 5 7 9
nv=1:-2:9
9 7 5 3 1 |
|
|
Term
|
Definition
:
1:5
1 2 3 4 5
x:y
iterates through x to y
regularly spaced |
|
|
Term
|
Definition
linspace(x,y,n) creates a vector with n values in the inclusive range [x,y], evenly (linearly) spaced
linspace(3,15,5)
3 6 9 12 15 |
|
|
Term
|
Definition
combine two vectors
vec1 = 1:2:9=[1 3 5 7 9]
vec2 = linspace(3,15,5)=[3 6 9 12 15]
newvec = [vec1 vec2]
newvec=
1 3 5 7 9 3 6 9 12 15 |
|
|
Term
|
Definition
aka subscript
element number
indexes start at 1 in MATLAB
vec=[3 12 7 1]
vec(2)=12 |
|
|
Term
|
Definition
also a vector
vec=[3 12 7 1]
vec(2:4)= [12 7 1]
uses colon operator : |
|
|
Term
|
Definition
used to get specified elements of another vector
index=[1 3 4]
vec=[ 2 6 7 3 9]
vec(index)=vec([1 3 4])=
[2 7 3]
|
|
|
Term
|
Definition
vec=[ 2 6 7 3 9]
assign vec(7)=12
vec=
[ 2 6 7 3 9 0 12]
inserts 0 for unassigned elements |
|
|
Term
|
Definition
mat(2,3) calls the element in the 2nd row and 3rd column
mat = 2 3 4 3 4 5
>> mat(1:2,2:3) 1st and 2nd row, 2nd and 3rd column ans = 3 4 4 5
: means all rows or all columns
mat(:,:)=mat
mat(2,:) - 2nd row, all columns
mat(:,3) - all rows, 3rd column
|
|
|
Term
|
Definition
when single index is used, unwinds by columns
ex.
mat = 2 3 4 3 4 5
mat(4)= 4 |
|
|
Term
|
Definition
replace 2nd row
mat(2,:)=5:7
replace 3rd column
mat(:,3)=[3 4]'
must have correct number of elements! |
|
|
Term
|
Definition
mat(4,:)=2:2:8
mat = 2 11 4 9 5 6 7 2 0 0 0 0 2 4 6 8
adds 0's to unassigned elements |
|
|
Term
|
Definition
will return either the number of rows or the number of columns, whichever is largest |
|
|
Term
|
Definition
gives dimensions of an array
vec=[-2 1 0 1]
size(vec)=
1 4
1x4
r x c |
|
|
Term
|
Definition
returns number of elements in an array |
|
|
Term
|
Definition
refers to the last column or row
mat(end, 1) calls the element in the last row, first column
|
|
|
Term
|
Definition
changes the dimensions of a matrix
iterates through the matrix columnwise |
|
|
Term
|
Definition
flips matrix from left to right
first column becomes last column etc |
|
|
Term
|
Definition
flips up to down
first row becomes last row etc |
|
|
Term
|
Definition
rotates the matrix clockwise 90 degrees
top-right corner becomes top-left corner |
|
|
Term
|
Definition
repmat(mat,m,n)
creates a larger matrix which consists of an m x n matrix copies of mat |
|
|
Term
|
Definition
[ ]
can be used to delete elements or subsets from vectors
vec=1:5
vec(3)=[]
vec=
1 2 4 5 |
|
|
Term
|
Definition
|
|
Term
|
Definition
Confusing the two division operators / and \
|
|
|