• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/47

Click to flip

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
into a column vector and vice versa.
MATLAB has a built-in function named transpose that perform this operation.
Thus transpose(Scores) gives exactly the same vector as ScoresC.


length

The number of elements in a given row or column array can be obtained using the
MATLAB built-in function length. For example
len = length(ScoresR)
produces the result
len = 4
Thus we know that the length of the vector ScoresR is 4 (it has 4 elements)

swapping two elements of a matrix using indices

temp = SCORES(1,3); % copy of score of 1st student
SCORES(1,3) = SCORES(2,3); % replace it with the 2nd student’s
SCORES(2,3) = temp; % replace 2nd student’s score with temp
Note that the use of a temporary variable is needed in order to make the switch!

size

One can find the size of an array using the built-in function size.



Dim = size(SCORES)

The statement [ numRows numCols ] = size(SCORES)
gives numRows = 4 and numCols = 3. The size function has an optional second argument that can be used to return either
the number of rows or columns. For example,
nRows = size(SCORES,1)
gives the number of rows (the first index), and
nCols = size(SCORES,2)
gives the number of columns (the second index).

the apostrophe

The apostrophe can also be used to take the transpose of an array if its elements are all
real quantities.
Assuming that to be the case, then transpose(SCORES) gives exactly the same array
as SCORES’.

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
arithmetic average) of a given array.



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
Vec = intendedFirst : increment : intendedEnd


The last element of Vec has a value closest to or equal to intendedEnd but does not
go beyond it.

linspace

The linspace function has three arguments firstElement, lastElement and
numberPoints, and creates a row vector whose first and last elements are given by
firstElement and lastElement respectively (unless numberPoints is less than 2)

accessing elements of an Array

Array = ARR



One can retrieve any element by specifying the indices. For example its element at
position
2, 3; theElement = ARR(2,3)



One can retrieve multiple elements from a given array using vector indices. For example,
Mtx1 = ARR([ 2 5 ],3)


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:
Mtx3 = ARR(4,[ 5 1 3 ])



Both the first and the second indices can be vectors:
MTX5 = ARR([5 2],2:4)



Notation: end gives the highest value that a given index can take. For example,
Mtx7 = ARR(3,2:end)




You can even do this
MTX8 = ARR(3:end,2:end)



adding element to an array

An element can be appended to an array.
The size of the array will be expanded just enough to accommodate the extra element.
The elements whose values are not specified are set to zero.


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
B, since they both have the same number
of rows, they can be concatenated side by side to obtain an
n by m + k array as follows
ABH = [ A B ]

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
times to produce larger array.

repmat;



Specifically given an array A, repmat(A,m,n) is an array obtained by replicating A m
times vertically and n times horizontally

deleting rows and columns from an array

Rows and columns can be deleted from an array by assigning them to an empty array.
The remaining rows and columns are repackaged so that the original array will have a
reduced size.

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
that r1 and r3 must be false.
There is really no need to see if b2 is true or not.


find

Given a vector of logical values, the built-in function find finds elements
whose values are true.
The function returns a vector (having the same row/column orientation as
the logical vector) of positions of the elements within the array whose
values are true.


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
the elements in the vector is true, and returns false if all the elements
are false.


all

The function all operates on a logical vector and returns true if all the
elements in the vector are true, and returns false if at least one of the
elements is false.


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
r with a mean of 0 and a standard deviation of
1. Normally distributed random numbers with any mean µ and standard deviation σ are
obtained by multiplying r by σ and shifting them by µ: σr + µ. The usage of the randn function is basically the same as the function rand. The biggest difference is it uses different generators since the distribution is different for
the uniformly distributed and the normally distributed random numbers.

discrete random variable

A (mathematical) variable is a discrete variable if it can only take on a countable number
of discrete values (there is a fixed nonzero distance between any two consecutive
values).
If it takes on those discrete values at random, then it is called a discrete random variable

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.