Addition, Subtraction, Multiplication & Division of Matrices

196 vues (au cours des 30 derniers jours)
Syed Shah
Syed Shah le 3 Avr 2019
Réponse apportée : Udoi le 6 Juil 2022
Write a Program in which Division, Multiplication, Addition & subtraction of two matrices are done by pressing 1,2,3 & 4 respectively.
  2 commentaires
madhan ravi
madhan ravi le 3 Avr 2019
@Syed: Ok so write a program, world hasn’t come to an end anyways.
Steven Lord
Steven Lord le 3 Avr 2019
This sounds like a homework assignment or school project. If it is, show us what you've done so far and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you're not sure even where to start because you're new to MATLAB, consider taking the MATLAB Onramp course to familiarize yourself with the basics of MATLAB. If you're not sure where to start because the question is not clear to you, you should ask your professor and/or your teaching assistant.

Connectez-vous pour commenter.

Réponses (1)

Udoi
Udoi le 6 Juil 2022
The addition of matrices is one of the basic operations that is performed on matrices. Two or more matrices of the same order can be added by adding the corresponding elements of the matrices. If A = [aijaij] and B = [bijbij] are two matrices with the same dimension, that is, they have the same number of rows and columns, then the addition of matrices A and B is: A+B = [aijaij] + [bijbij] = [aij+bijaij+bij].
The matrices for addition can be either a square matrix or a rectangular matrix, but the matrices should be of the same order.
The addition of matrices follows similar properties of the addition of numbers: commutative law, associative law, additive inverse, additive identity, etc. The following properties help in the addition matrix operations.
  • Commutative Property of matrix addition for the matrices A = [aijaij] and B = [bijbij] of same order m × n, is A + B = B + A.
  • Associative Property of matrix addition for the matrices A = [aijaij], B = [bijbij] and C = [cijcij] of same order m × n, is (A+B)+C = A+(B+C).
  • Additive Identity of matrix addition for a matrix A = [aijaij] of order m × n, is the zero matrix O of order m × n such that A + O = O + A = A.
  • Additive Inverse of matrix addition for the matrix A = [aijaij] of the order m × n, is -A = [aijaij] of the same order m × n such that A + (-A) = O = A + (-A)..
  • Transpose Property of matrix addition for two matrixes A = [aijaij] and B = [bijbij] of same order is, (A + B)T = AT + BT
  • Determinant Property of matrix addition for two matrixes A = [aijaij] and B = [bijbij] of same order is, |A + B| = |A| + |B|
Subtraction - Matrix Operations
Subtraction of matrices is a matrix operation of element-wise subtraction of matrices of the same order, that is, matrices that have the same number of rows and columns. In subtracting two matrices, we subtract the elements in each row and column, from the respective elements in the row and column of another matrix.
Consider two matrices A and B of the same order 'm × n', where m is the number of rows and n is the number of columns of the two matrices, denoted as, A = [aijaij] and B = [bijbij]. Now, the difference of the two matrices A and B is given as: A - B = [aijaij] - [bijbij] = [aijbijaijbij], where ij denotes the position of each element in ith row and jth column. The dimension of the difference matrix, that is, A - B is also m × n'.
The most important necessity for the subtraction of matrices to hold all these properties is that the subtraction of matrices is defined only if the order of the matrices is the same.
  • The number of rows and columns in the respective matrices should be the same for the subtraction of matrices.
  • The subtraction of matrices is not commutative, that is, A - B ≠ B - A
  • The subtraction of matrices is not associative, that is, (A - B) - C ≠ A - (B - C)
  • The matrix subtraction from itself results in a null matrix, that is, A - A = O.
  • Subtraction of matrices is the addition of the negative of a matrix to another matrix, that is, A - B = A + (-B).
Multiplication - Matrix Operations
Matrix multiplication is a binary matrix operation performed on matrix A and matrix B, when both the given matrices are compatible. The primary condition for the multiplication of two matrices is the number of columns in the first matrix should be equal to the number of rows in the second matrix, and hence the order of the matrix is important. The multiplication of matrices does not follow commutative law, AB ≠ BA,.
Two matrices A and B are said to be compatible if the number of columns in A is equal to the number of rows in B. The resultant matrix for the multiplication of a matrix A of order m × n with a matrix B of order n × p, is a matrix C of the order m × p.
For the multiplication of two matrices, the elements of the rows of the matrix are multiplied with the elements of the columns of the next matrix, and the summation of this product results in the elements of the resultant product matrix. This can be more clearly understood from the below multiplication of two matrices of order 3 x 3.
There following properties of matrix multiplication are helpful for performing multiplication matrix operation.
  • Non-Commutative for matrix multiplication: Matrix multiplication is non-commutative, and the product AB is not equal to the product BA, AB ≠ BA.
  • Distributive proper over the addition of matrices for Matrix multiplication of matrix A and matrix B with another matrix C is A(B + C) = AB + BC.
  • Matrix multiplication with a Scalar k for matrices A and B, is defined as k(AB) = (kA)B = A(Bk).
  • Transpose property of matrix multiplication for two matrices A and B can be given as, (AB)T = BTAT
  • Complex Conjugate property of matrix multiplication for two matrices A and B is (AB)* = B*A*
  • Associativity for matrix multiplication for three matrices A, B, and C, such that the products (AB)C and A(BC) are defined, as (AB)C = A(BC).
The scalar multiplication of matrix is the product of the scalar constant value with each of the elements of the matrix. The following properties of scalar multiplication of matrices is helpful in easily performing scalar multiplication of matrices. Here we have two mtrices A, B and k, l are the scalar constant values.
  • K(A + B) = KA + KB
  • (K + l)A = KA + lA
  • (Kl)A = K(lA) = l(KA)
Transpose Operation of a Matrix
The matrix resulting from a given matrix after changing or reversing its rows to columns and columns to rows is called the transpose of a matrix. A rectangular array of numbers or functions that are arranged in the form of rows and columns is called a matrix. This array of numbers are called either entries or elements of a matrix. After finding the transpose of a matrix, the order of the matrix is changed from an order of m × n to an order of n × m.
Here for matrix A the elements of the first row have been written in the first column of a new matrix, and the elements of the second row have been written in the second column of a new matrix. And this new matrix is denoted as AT, which is the transpose of the given matrix A.
The order of a matrix represents the number of rows and columns in a given matrix. The horizontal lines of the elements are all called the rows of the matrix which is denoted by n, and the vertical lines of the elements are called the columns of the matrix which is denoted by m. Together, they represent the order of a matrix, which is written as n × m. And the order of the transpose of the given matrix is written as m x n.
In the above example, we can see that the given matrix of order 2 × 3. The elements of the first row [-2, 5, 6] are written in the first column, and the elements in the second row [5, 2, 7] are written in the second column to obtain the transpose matrix. The transpose of the matrix A is AT and has an order of 3 x 2.
There are various properties associated with the transposition operation in matrices, for matrices A and B, given as,
  • (AT)T = A
  • (A + B)T = AT + BT, A and B being of the same order.
  • (KA)T= KAT, K is any scalar(real or complex).
  • (AB)T= BTAT, A and B being conformable for the product AB. (This is also called reversal law.)
Inverse Operation of a Matrix
The inverse of a matrix is another matrix operation, which on multiplication with the given matrix gives the multiplicative identity. For a matrix A, its inverse is A-1, and A.A-1 = I. The general formula for the inverse of a matrix of order 2 × 2 is equal to the adjoint of a matrix divided by the determinant of a matrix. The inverse of the matrix exists only if the determinant of the matrix is a non-zero value. The matrix whose determinant is non-zero and for which the inverse matrix can be calculated is called an invertible matrix.
A = (abcd)(abcd)
A-1 = 1adbc(dbca)1adbc(dbca)
A-1 = 1|A|1|A| Adj A
Further for matrices of higher-order, the inverse of a matrix can be computed by dividing the adjoint of a matrix by the determinant of the matrix. The inverse of a matrix can be calculated by following the below-given steps:
  • Step 1: Calculate the minor for the given matrix.
  • Step 2: Transform the obtained matrix into the cofactor matrix
  • Step 3: Then, find the adjoint matrix.
  • Step 4: Divide the adjoint matrix with the determinant of the matrix.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by