分享兴趣,传播快乐,
增长见闻,留下美好。
亲爱的您,这里是LearningYard学苑!
今天小编为大家带来文章
“越览(44)——Matlab入门学习(3)
之矩阵运算。”
欢迎您的访问。
Share interest, spread happiness,
increase knowledge,and leave beautiful.
Dear, this is LearningYard Academy!
Today, the editor brings you the article
“Yue Lan (44)——Matlab introductory
learning (3): Matrix operation”
Welcome to visit!
一、内容摘要(Summary of Content)
本次推文将从内容摘要、思维导图、入门学习来介绍Matlab入门学习(3)之矩阵运算。
This tweet will introduce the matrix operation of Matlab introductory learning (3) from content summary, mind map, and introductory learning.
二、思维导图(Mind Maping)
三、入门学习(introductory learning)
(一)矩阵构建(Matrix construction)
首先介绍四种常见的建立矩阵的方法。
First, four common methods for establishing matrices are introduced.
1. 直接输入法(Direct input method)
最简单的方法是直接在命令窗口或脚本中定义矩阵。可以通过列出所有的元素来创建矩阵,元素之间用空格或逗号分隔,不同行之间用分号或换行分隔。例如,创建一个 3x4 的矩阵 A ,代码如下所示:
The easiest way to do this is to define a matrix directly in a command window or script. You can create a matrix by listing all the elements, separated by spaces or commas, and by semicolons or newlines. For example, create a 3x4 matrix A with the following code:
运行结果如下图所示:
The running result is shown as follows:
2. 使用内置函数(Using built-in functions)
MATLAB 提供了一些内置函数来方便地创建特定类型的矩阵。例如zeros()函数能够创建一个全零矩阵,ones()函数能够创建一个全一矩阵,rand()函数能够创建一个由随机数填充的矩阵。接下来举例说明以上内置函数的使用方法,代码如下图所示:
MATLAB provides some built-in functions to easily create specific types of matrices. For example, the zeros () function can create an all-zero matrix, the ones () function can create an all-one matrix, and the rand () function can create a matrix filled with random numbers. The following example illustrates how to use the above built-in functions. The code is shown in the following figure:
运行结果如下所示:
The running result is as follows:
3. 向量转化为矩阵(Convert a vector to a matrix)
现有一个一维向量b,并且希望将其转换成一个矩阵,可以使用 reshape 函数。reshape(b,2,5)表示将向量b转化为一个2行5列的矩阵。代码如下图所示:
If you have a one-dimensional vector b and want to convert it into a matrix, you can use the reshape function. Reshape (b, 2, 5) means to convert the vector b into a matrix with 2 rows and 5 columns. The code is shown below:
运行结果如下图所示:
The running result is shown as follows:
4. 使用循环填充矩阵(Fill a matrix with a loop)
对于一些需要按照特定规则填充的矩阵,可以使用循环来实现。例如,有一个包含 12 个元素的行向量c,并想将其转换成一个 3x4 的矩阵 C,可以通过循环来填充矩阵。代码示例如下:
For some matrices that need to be filled according to specific rules, loops can be used to implement them. For example, if you have a row vector c with 12 elements and want to convert it to a 3x4 matrix C, you can fill the matrix with loops. The code example is as follows:
运行结果如下图所示:
The running result is shown as follows:
(二)矩阵运算(Matrix operation)
接下来将介绍一些基本的矩阵运算。
Next, we will introduce some basic matrix operations.
1. 矩阵加减法(Matrix addition and subtraction)
矩阵加减法要求两个矩阵具有相同的维度。两个矩阵对应位置的元素相加或相减即可得到结果矩阵。示例代码如下:
Matrix addition and subtraction requires two matrices to have the same dimensions. The resulting matrix is obtained by adding or subtracting the elements at the corresponding positions of the two matrices. The example code is as follows:
运算结果如下所示:
The result of the operation is as follows:
2. 矩阵乘法(Matrix multiplication)
矩阵乘法需要满足一定的维度条件,即第一个矩阵的列数必须等于第二个矩阵的行数。结果矩阵的维度为第一个矩阵的行数乘以第二个矩阵的列数。
Matrix multiplication requires a certain dimensional condition, that is, the number of columns of the first matrix must be equal to the number of rows of the second matrix. The dimension of the resulting matrix is the number of rows of the first matrix multiplied by the number of columns of the second matrix.
矩阵对应数值相乘是指两个矩阵的相同位置上的元素相乘。这种乘法要求两个矩阵具有相同的维度。
Matrix correspondence Multiplication refers to the multiplication of elements at the same position in two matrices. This multiplication requires that both matrices have the same dimensions.
示例代码如下:
The example code is as follows:
运算结果如下所示:
The result of the operation is as follows:
3. 矩阵除法(Matrix division)
矩阵除法是指通过矩阵运算来求解线性方程组的一种方法。具体来说,矩阵除法使用斜杠符号/ 来表示。
Matrix division is a method of solving linear equations by matrix operations. Specifically, matrix division is represented by the slash symbol/.
矩阵对应数值相除是指两个矩阵的相同位置上的元素相除。这种运算要求两个矩阵具有相同的维度。对应数值相除使用双斜杠符号 ./ 来表示。
Matrix-to-value division refers to the division of elements at the same position in two matrices. This operation requires two matrices to have the same dimensions. The corresponding numerical division is represented by the double slash symbol./.
示例代码如下所示:
The example code is as follows:
运行结果如下所示:
The running result is as follows:
4. 矩阵乘方(Matrix multiplier)
矩阵乘方是指矩阵与其自身的多次相乘。矩阵乘方使用符号 ^ 来表示。具体来说,矩阵 A的 n 次幂即矩阵 A 与自身相乘 n 次。
Matrix power refers to the multiplication of a matrix by itself many times. Matrix power is represented by the symbol ^. Specifically, the n-power of a matrix A is multiplied by itself n times.
矩阵所有数值的乘方是指矩阵中的每个元素分别乘以其自身的次数。在 MATLAB 中,这种运算使用符号 .^ 来表示。这种运算要求对每个元素进行独立的乘方运算。
The multiplication of all values in a matrix is the number of times each element in the matrix is multiplied by itself. In MATLAB, this operation is represented by the symbol. ^. This operation requires an independent multiplication operation for each element.
示例代码如下:
The example code is as follows:
运行结果如下所示:
The running result is as follows:
5. 矩阵转置(Matrix transpose)
矩阵转置是将矩阵的行变成列,列变成行的过程,通常借助单引号’来实现。示例代码如下所示:
Matrix transpose is the process of turning the rows of a matrix into columns and columns into rows, usually with the help of single quotes '. The example code is as follows:
运算结果如下所示:
The result of the operation is as follows:
今天的分享就到这里了。
如果您对文章有独特的想法,
欢迎给我们留言,让我们相约明天。
祝您今天过得开心快乐!
That's all for today's sharing.
If you have a unique idea about the article,
please leave us a message,
and let us meet tomorrow.
I wish you a nice day!
文案|yyz
排版|yyz
审核|hzy
翻译:谷歌翻译
参考资料:Chat GPT、哔哩哔哩
本文由LearningYard学苑整理发出,如有侵权请在后台留言!