Section 5 basic matrix calculation using Matlab
MATLAB mathematical software can perform various complex operations on the matrix. Below are some examples of simple operations.
Example 18: generate a matrix. Set
Solution: MATLAB has many functions to generate different types of matrices. When you input the following commands in the MATLAB window, all elements of the matrix must be in a pair of square brackets, different elements in the same row are separated by commas (,) or spaces, and different rows are separated by semicolons (;). If you do not end with a semicolon after the input, the input content is not displayed and ended with a semicolon, displays the input result immediately.
> A = [, 7;-, 9;, 1]
A =
> B = [3; 1; 4]
> C = [2, 0,-1]
C =
Example 19 known
Solution: Enter the following command in the MATLAB window:
> A = [1,-; 2,-; 3,-];
> B = [3,-;, 1; 1,-];
> X = a + B
X =
> Y = AB
Y =
Example 20
Solution: Enter the following command in the MATLAB window:
> A = [3,-,-1;,; 1,-, 2;,];
> DETA ------ the determinant function of the matrix is det ()
Ans = 4
> A' ------ calculate the transpose of the matrix. Use single quotation marks directly and use a' instead of
Ans =
> Inv (a) ------ calculate the Inverse Matrix Function of the matrix as inv ()
Ans =
> A ^ 2
Ans =