In this lab, you'll solve some simple matrix creation and manipulation exercises based on what you've learned so far in this section. The key takeaway here is to be able to understand how to use indexing with matrices and vectors while applying some basic operations.
In this lab you will:
- Find the shape of vectors and matrices
- Access and manipulate individual scalar components of a matrix
- Create vectors and matrices using Numpy and Python
So $A =
\left[ {\begin{array}{cc}
1402 & 191 \
1371 & 821\
949 & 1437 \
147 & 1448 \
\end{array} }\right]
$
and
$
B =
\left[ {\begin{array}{ccc}
1 & 2 & 3 \
4 & 5 & 6\
\end{array} }\right]
$
# Code here
# Code here
Print the following elements from
- First row and first column
- First row and second column
- Third row and second column
- Fourth row and first column
# Code here
- Create an
$(3 \times 3)$ Numpy array with all zeros (usenp.zeros()
) - Access each location
$(i,j)$ of this matrix and fill in random values between the range 1 and 10
# Code here
- Create two
$(4 \times 4)$ zero-valued matrices and fill with random data using the function - Add the matrices together in Numpy
- Print the results
# Code here
In this lab, we saw how to create and manipulate vectors and matrices in Numpy. We shall now move forward to learning more complex operations including dot products and matrix inversions.