matlab的基礎知識(周一分享三十七)
2023-07-24 09:46:14 4
Matlab入門學習
Getting started with Matlab
分享興趣,傳播快樂,
增長見聞,留下美好。
親愛的您,
這裡是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.
方法二:使用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.
方法三:使用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.
今天的分享就到這裡了。
如果您對今天的文章有獨特的想法,
歡迎給我們留言,
讓我們相約明天。
祝您今天過得開心快樂!
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
審核|任務達人
,