百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术资源 > 正文

越览(44)——Matlab入门学习(3)之矩阵运算

moboyou 2025-04-25 13:10 31 浏览

分享兴趣,传播快乐,

增长见闻,留下美好。

亲爱的您,这里是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学苑整理发出,如有侵权请在后台留言!

相关推荐

Excel技巧:SHEETSNA函数一键提取所有工作表名称批量生产目录

首先介绍一下此函数:SHEETSNAME函数用于获取工作表的名称,有三个可选参数。语法:=SHEETSNAME([参照区域],[结果方向],[工作表范围])(参照区域,可选。给出参照,只返回参照单元格...

Excel HOUR函数:“小时”提取器_excel+hour函数提取器怎么用

一、函数概述HOUR函数是Excel中用于提取时间值小时部分的日期时间函数,返回0(12:00AM)到23(11:00PM)之间的整数。该函数在时间数据分析、考勤统计、日程安排等场景中应用广泛。语...

Filter+Search信息管理不再难|多条件|模糊查找|Excel函数应用

原创版权所有介绍一个信息管理系统,要求可以实现:多条件、模糊查找,手动输入的内容能去空格。先看效果,如下图动画演示这样的一个效果要怎样实现呢?本文所用函数有Filter和Search。先用filter...

FILTER函数介绍及经典用法12:FILTER+切片器的应用

EXCEL函数技巧:FILTER经典用法12。FILTER+切片器制作筛选按钮。FILTER的函数的经典用法12是用FILTER的函数和切片器制作一个筛选按钮。像左边的原始数据,右边想要制作一...

office办公应用网站推荐_office办公软件大全

以下是针对Office办公应用(Word/Excel/PPT等)的免费学习网站推荐,涵盖官方教程、综合平台及垂直领域资源,适合不同学习需求:一、官方权威资源1.微软Office官方培训...

WPS/Excel职场办公最常用的60个函数大全(含卡片),效率翻倍!

办公最常用的60个函数大全:从入门到精通,效率翻倍!在职场中,WPS/Excel几乎是每个人都离不开的工具,而函数则是其灵魂。掌握常用的函数,不仅能大幅提升工作效率,还能让你在数据处理、报表分析、自动...

收藏|查找神器Xlookup全集|一篇就够|Excel函数|图解教程

原创版权所有全程图解,方便阅读,内容比较多,请先收藏!Xlookup是Vlookup的升级函数,解决了Vlookup的所有缺点,可以完全取代Vlookup,学完本文后你将可以应对所有的查找难题,内容...

批量查询快递总耗时?用Excel这个公式,自动计算揽收到签收天数

批量查询快递总耗时?用Excel这个公式,自动计算揽收到签收天数在电商运营、物流对账等工作中,经常需要统计快递“揽收到签收”的耗时——比如判断某快递公司是否符合“3天内送达”的服务承...

Excel函数公式教程(490个实例详解)

Excel函数公式教程(490个实例详解)管理层的财务人员为什么那么厉害?就是因为他们精通excel技能!财务人员在日常工作中,经常会用到Excel财务函数公式,比如财务报表分析、工资核算、库存管理等...

Excel(WPS表格)Tocol函数应用技巧案例解读,建议收藏备用!

工作中,经常需要从多个单元格区域中提取唯一值,如体育赛事报名信息中提取唯一的参赛者信息等,此时如果复制粘贴然后去重,效率就会很低。如果能合理利用Tocol函数,将会极大地提高工作效率。一、功能及语法结...

Excel中的SCAN函数公式,把计算过程理清,你就会了

Excel新版本里面,除了出现非常好用的xlookup,Filter公式之外,还更新一批自定义函数,可以像写代码一样写公式其中SCAN函数公式,也非常强大,它是一个循环函数,今天来了解这个函数公式的计...

Excel(WPS表格)中多列去重就用Tocol+Unique组合函数,简单高效

在数据的分析和处理中,“去重”一直是绕不开的话题,如果单列去重,可以使用Unique函数完成,如果多列去重,如下图:从数据信息中可以看到,每位参赛者参加了多项运动,如果想知道去重后的参赛者有多少人,该...

Excel(WPS表格)函数Groupby,聚合统计,快速提高效率!

在前期的内容中,我们讲了很多的统计函数,如Sum系列、Average系列、Count系列、Rank系列等等……但如果用一个函数实现类似数据透视表的功能,就必须用Groupby函数,按指定字段进行聚合汇...

Excel新版本,IFS函数公式,太强大了!

我们举一个工作实例,现在需要计算业务员的奖励数据,右边是公司的奖励标准:在新版本的函数公式出来之前,我们需要使用IF函数公式来解决1、IF函数公式IF函数公式由三个参数组成,IF(判断条件,对的时候返...

Excel不用函数公式数据透视表,1秒完成多列项目汇总统计

如何将这里的多组数据进行汇总统计?每组数据当中一列是不同菜品,另一列就是该菜品的销售数量。如何进行汇总统计得到所有的菜品销售数量的求和、技术、平均、最大、最小值等数据?不用函数公式和数据透视表,一秒就...