Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
47 Cards in this Set
- Front
- Back
Index |
An index is used together with the variable name of the array to access each value.
The value stored in the n-th element is accessed by Scores(n). |
|
disp(ygrhufjdc) |
display that (x,y) shite. For indexing maxrices disp(Buetto(6,9)
|
|
transpose |
In linear algebra, there is an operation called the transpose which converts a row vector
|
|
length |
The number of elements in a given row or column array can be obtained using the |
|
swapping two elements of a matrix using indices |
temp = SCORES(1,3); % copy of score of 1st student |
|
size |
One can find the size of an array using the built-in function size.
|
|
the apostrophe |
The apostrophe can also be used to take the transpose of an array if its elements are all |
|
sum |
TotalExams = sum(SCORES,1); columns
TotalStudents = sum(SCORES,2); rows
|
|
function for average |
The built-in function mean can be used in the same way, to compute the mean (or the
can be used in same 1,2 specification as sum for a matrix |
|
creates an m by n array whose elements are all zeros. |
zeros(m,n) |
|
creates an array the same size as SCORES with elements all set to zeros. |
zeros(size(Scores)) |
|
creates an m by n array whose elements are all ones.
|
ones(m,n) |
|
creates an array the same size as SCORES with elements all set to ones |
ones(size(Scores)) |
|
create an n deminsion identity matrix |
eye(n) |
|
efficient way to generate a large, patterned vector |
Colon operator.
Given three numbers intendedFirst, increment, and intendedEnd, the statement |
|
linspace |
The linspace function has three arguments firstElement, lastElement and |
|
accessing elements of an Array |
Array = ARR
One can retrieve any element by specifying the indices. For example its element at
One can retrieve multiple elements from a given array using vector indices. For example, gives us 2,3 and 5,3 of ARR
Mtx2 = ARR(2,2:4)
The vector indices need not be in ascending or descending order, for example:
Both the first and the second indices can be vectors:
Notation: end gives the highest value that a given index can take. For example,
You can even do this
|
|
adding element to an array |
An element can be appended to an array. Scores(6,9)= 75 % all else in new rs and cs will be 0s %%use () not [] |
|
making 1 big matrix from 2 little guys, row.wise |
*must have same #rows
Given an n by m array A and an n by k array |
|
Making 1 big matrix from 2 little guys, column.wise |
*must have same number of columns
given A (n,k) and C(r,k);
ACV = [ A; C ] |
|
replicate a given array a certain number of |
repmat;
Specifically given an array A, repmat(A,m,n) is an array obtained by replicating A m |
|
deleting rows and columns from an array |
Rows and columns can be deleted from an array by assigning them to an empty array. |
|
how do i delete partial rows or partial columns of a jawn? |
you dont.
deleting a partial row or a partial column from a 2D array is illegal.
I can do this with 1Xn vectors doe
|
|
Entering Data from the Keyboard at runtime |
For numerical input, R = input(’How many apples’) |
|
elementwise addition or subtraction |
+
-
|
|
elementwise multiplication, division, exponetiation |
.*
./
.^
for two matrices, they must be same size |
|
Log) equal t0 |
== |
|
log) not equal to |
~= |
|
log) strictly greater |
> |
|
log) greater than or equal to |
>= |
|
log) strictly less than |
< |
|
log) less than or equal to |
<=
this one looks like a dick. |
|
Binary logic operator
And
|
& |
|
Binary logic operator AND with short circuit evaluation for scalers
|
&& |
|
Binary logic operator inclusive OR |
| |
|
Binary logic operator inclusive OR with short circuit evaluation for scalers |
|| |
|
Binary logic operator, exclusive OR |
xor |
|
what is the short circuit evaluation |
Note that in evaluating r1 and r3, the fact that b1 is false already implies
|
|
find |
Given a vector of logical values, the built-in function find finds elements
|
|
create a vector containing all true elements of a logical stipulation
|
use vector indexing
Vec is some bullsh8t Fd= find(Vec > something else)
Vec(Fd) = all elements of origional Vec that are > something else |
|
logical indexing |
Rd= rand(1,5)
Log=( Rd > .5 )
RdLog= Rd(Log)
Results in vector of values of Rd that satisfy Log without bullsh8t 0s;
|
|
any |
The function any operates on a logical vector and returns true if any of
|
|
all |
The function all operates on a logical vector and returns true if all the
|
|
generate random numbers over interval [a,b] |
v = a + (b − a)u
where u is a random number (or vec/array of them) normal rand |
|
randn |
In MATLAB the function randn generates normally distributed random points |
|
discrete random variable |
A (mathematical) variable is a discrete variable if it can only take on a countable number |
|
discrete variable |
If a variable can take on any value between two specified values, it is called a continuous variable; otherwise, it is called a discrete variable. Some examples will clarify the difference between discrete and continuous variables. * Suppose we flip a coin and count the number of heads. The number of heads could be any integer value between 0 and plus infinity. However, it could not be any number between 0 and plus infinity. We could not, for example, get 2.5 heads. Therefore, the number of heads must be a discrete variable. |