matlab week 2.1 Flashcards

1
Q

what should you do to matrices to properly store data?

A

transpose

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

: operator in indexing (i.e (2, :))

A

serves as ‘select all’ and allows you to select specific rows or columns

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

to a computer everything is ____

A

numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

ASCII

A

system that stores letters and special characters as number for computer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

uint(‘a’)

A

returns ASCII number, in this case 97

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

char( 97 )

A

returns character that ASCII number represents, in this case a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

num2str()

A

converts numbers to string with ASCII represented characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

str2num()

A

converts string to ASCII number representation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

adding a number to a string…

A

just concatenates with ASCII rep of number, doesn’t do what you want

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

dimensions of array being concatenated must be…

A

the same

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

multidimensional matrix

A

third layer that allows multiple ‘pages’ in a book of code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

find(x)

A

if you have an array x

locates all nonzero elements of array x and outputes the corresponding indices in x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

find (X, k, ‘first’)

A

returns the first k indices corresponding to nonzero elements of the array
-> you can do the same with ‘last’ and it will return first k indices from the back

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

[row, column] = find(B)

A

finds indies of multidimensional matrix B that are nonzero and stores corresponding row numbers in variable row and column number in variable column

you can add optional ‘v’ to the outputs and that will return what the nonzero numbers are

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what if X is a logical expression?
[row, col, v] = find( A == 9)

A

vector v is then logical and will contain the nonzero elements of logical array obtained by evaluating X

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

min function

A

returns smallest element in vectors, and smallest of each COLUMN in matrices

17
Q

[M, I] = min(A)

A

returns indices corresponding to a minimum
M is min of each column
I is their indices (row number)

18
Q

M = min(X, [], DIM)

A

finds minimum along dimension dim
1 means from each column
2 means from each row

19
Q

max function

A

similar format as min function but finds the largest values of a matrix

20
Q

mean function

A

takes average value of elements for vector, for matrices it takes the average for each column and returns row vector

21
Q

sum function

A

takes the sum of all elements for vectors and returns vector with sum for each column for matrices

22
Q

sort function

A

reorganizes data, default is smallest to largest but to reverse add ‘descend’

23
Q

sortrows function

A

sorts rows based on specified column
ex:
sortrows(X, 1)
sorts rows of matrix X based on first column

24
Q

input(‘prompt’) vs input(‘prompt’, ‘s’)

A

adding ‘s’ takes user input in as a string

25
Q

disp function

A

displays text and variables into the command window