Vectors & Matrices Flashcards

1
Q

How do we create an array from one value to another?

Alternative with jump argument?

A

We use colons :

X = i : j (From i through j)

Alternative:

X = i : k : j

(The k is the jump value)

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

How do we transpose a matrix or vector X?

A

By using single apostrophe:

X’ is the transpose of X

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

How do we generate an array of 100 elements evenly spaced from an initial value toca final one?

A

By using: linspace(initial, final)

You can also add an extra argument:

linspace(initial, final, amount)

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

How do we manually create vectors or matrices?

A

By using brackets:

X = [1 2 3] or [1, 2, 3]

Use space or commas for separating elements in the same row.

X = [1; 2; 3]

Use semicolon for separating elements from columns.

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

Example of a matrix?

A

A = [ 1, 2; 3, 4]

This is 2x2 matrix.

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

If A is a matrix, what do the following mean?

A + 2 , A - 2 , A* 2 or 2*A, A/2

A

Those operations will add, subtract, multiply or divide by 2 to each element of the matrix A.

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

How do we apply elementwise operations to vectors or matrices?

A

We add a dot to the vector/matrix. For instance:

x.^2 will square each element

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

Most common types of matrices with commands?

A

All ones matrix: ones(m, n)
All zeros: zeros(m,n)
Identity: eye(n)

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

How do we access elements in a matrix or array?

A

We use parenthesis, for instance, if A is the matrix:

A(i, j) gives you the element in the ith row and jth column.

If A is an array, then we do:

A(j) access the jth element.

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

How do we access the last element of an array A?

A

By following this command:

A(end)

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

How can I assign a value to an entry of a matrix or array A?

A

By doing this: A(i, j) = value

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

What if i wanted to obtain all elements of a row or column of a matrix A?

A

A(2, : ) gives you all elements of the second row of the matrix

A(: , 2) gives you all elements of the second column

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