matlab的基础知识(周一分享三十七)

Matlab入门学习

Getting started with Matlab

matlab的基础知识(周一分享三十七)(1)

分享兴趣,传播快乐,

增长见闻,留下美好。

亲爱的您,

这里是LearingYard学苑!

今天小编为大家带来Matlab入门学习。

欢迎您的用心访问!

本期推文阅读时长大约5分钟,请您耐心阅读。

Share interests, spread happiness,

increase knowledge, and leave beauty behind.

Dear you,

this is LearningYard Academy!

Today,the editor brings you Matlab introductory learning.

Welcome your visit!

The reading time of this tweet is about 5 minutes, please read it with patience.

今天小编为大家介绍三种方法将行向量转换为矩阵,以a=[1 2 3 4 5 6 7 8 9]转换成3*3的矩阵形式为例。

Today, I'm going to show you three ways to convert a row vector into a matrix, using the matrix form of a = [1 2 3 4 5 6 7 8 9] as an example.

方法一:将行向量用分号分开,就变成了矩阵。

Method 1: separate the row vectors with semicolons, and you have a matrix.

matlab的基础知识(周一分享三十七)(2)

matlab的基础知识(周一分享三十七)(3)

方法二:使用reshape,vec2math函数。reshape()将指定的矩阵变换成特定维数矩阵。reshape(a,3,3)',第一个参数是指要操作的向量,第二个参数是要重构的行数,第三个参数是要重构的列数,“ ' ”指转置。vec2mat()把向量转换成矩阵。vec2mat(a,3)第一个参数是指要操作的向量,第二个参数是规定的列数。

Method Two: use the reshape, vec2math function. Reshape () transforms the specified matrix into a matrix of specific dimensions. Reshape (A, 3,3) ' , the first parameter is the vector to be manipulated, the second parameter is the number of rows to be refactored, the third parameter is the number of columns to be refactored, and the'”'” is the transpose. VEC2MAT () converts a vector into a matrix. VEC2MAT (A, 3) the first parameter is the vector to operate on, and the second parameter is the specified number of columns.

matlab的基础知识(周一分享三十七)(4)

matlab的基础知识(周一分享三十七)(5)

matlab的基础知识(周一分享三十七)(6)

matlab的基础知识(周一分享三十七)(7)

方法三:使用for循环。首先生成3*3的全零矩阵,i指行数,j指列数,c(i,:)=a((1:3) (i-1)*3)指取每n个数作为一行存入c数组。

Method Three: Use A for loop. The first step is to generate a 3 * 3 all-zero matrix, the number of rows of I, the number of columns of J, and C (I, :) = a ((1:3) (I-1) * 3) , which takes every n numbers and stores them as a row in the C array.

matlab的基础知识(周一分享三十七)(8)

matlab的基础知识(周一分享三十七)(9)

今天的分享就到这里了。

如果您对今天的文章有独特的想法,

欢迎给我们留言,

让我们相约明天。

祝您今天过得开心快乐!

That's it for today's sharing.

If you have a unique idea about today’s article,

welcome to leave us a message,

let us meet tomorrow.

I wish you a happy day today!

参考资料:谷歌翻译、百度、哔哩哔哩

本文由LearningYard学苑原创,如有侵权请在后台留言!

文字|Zheng

排版|Zheng

审核|任务达人

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页