Ad Math Lab 5
Ad Math Lab 5
: 2058471
Course : BSECE 2nd Year Date : April 28,2025
Objectives: Perform different mathematical operations in a matrix & plot results from
matrix operations
Discussion: Two matrices are equal if and only if their corresponding elements are
equal. If Matrix A and Matrix C are two matrices of the same size, we can define their
sum by A + C and their difference by A - C. A scalar can be multiplied to a matrix by
multiplying every element of a matrix by the scalar. In multiplying matrix by another
matrix, the two matrices should be conformable. The number of columns of the first
matrix should be equal to the number of rows of the second matrix.
Instructions: Perform the following accordingly, then answer the questions that follow.
Place your answers on the space provided. Place the result of the following MATLAB
instructions on the space provided. The symbol “>>” indicates that you must show the
results in the space provided.
MATLAB Session
>> a = [1 2 3 4 6 4 3 4 5]
4. Now let us add 2 to each element of our vector, a, and store the result in a new
vector. Notice how MATLAB requires no special handling of vector or matrix
math.
>> b = a + 2
5. Creating graphs in MATLAB is as easy as one command. Let us plot the result of
our vector addition with grid lines.
>> plot(b)
>> grid on
6. MATLAB can make other graph types as well, with axis labels.
>> bar(b)
>> xlabel(‘ Sample # ’)
>> ylabel(‘ Pounds ’)
7. MATLAB can use symbols in plots as well. Here is an example using stars to
mark the points. MATLAB offers a variety of other symbols and line types.
>> plot(b, ‘*’)
>> axis([0 10 0 10 0])
8. In the previous activity, the demonstration of creating matrices was done. Create
two matrices.
9. Now, let us multiply the two matrices. Note again that MATLAB does not require
you to deal with matrices as collection of numbers. MATLAB knows when you
are dealing with matrices and adjusts your calculations accordingly.
>> C = A * B
10. Let use the matrix A to solve the equation, A*x = b. we do this by using the \
(backslash) operator.
>> b = [1;3;5]
>> x = A\b
>> r = A*x – b
11. MATLAB has functions for nearly every type of common matrix calculation. There
are functions to obtain eigenvalues as well as the singular values.
>> eig(A)
>> svd(A)
1. A + B
2. B + A
3. A – B
4. B – A
5. 3A – 2B
6. 3(2A-B)
7. AT, BT
8. (A + B)T
9. A3 + 2A
10. BBT
B. Can multiplication occur
between the following
matrices? If so, compute it.
1.
2.
3.
4.
5.