Tips for Matlab Matrix
Matlab is very useful for calculating or processing data about matrices to the extent that it is a matrix calculator. Assuming that you know basic matrix and matlab knowledge, I will write down here some tips that are easy to forget but useful. If you need any function, search 'ctrl + f' and check it then.
1. Transposition Matrix
All you have to do is put ' after the procession.
2. Creating a Matrix with Only 0 or 1
zeros(x,y) creates an x-by-y matrix in which all elements are zero. Similarly, ones(x,y) become an x-by-y matrix in which all elements are one.
3. Counting Rows or Columns
The length() function allows you to count the number of columns or rows in a matrix. Output will be large numbers between the number of rows or columns. If you want to know the total x-by-y value, you can use size(). For Example, you can easily get the number of matrices as variables when you program with a macro or when you are not sure about the data exactly.
4. Extraction and Division of Elements in a Matrix
In a matrix of different elements, if you want to take only the value of an element at a particular location, you can extract the element at the x,y location in the form of an "matrix(x,y)". If you write down the first and last position of the colon (: ) in the function input, you can also use a partial matrix. If you want to bring all of one row or column, it's convenient to use only ': '.
5. Merging Matrices
Conversely, if you want to combine the two matrices, you can tie them in square brackets as shown in "[Parallel 1 Matrix 2]." Likewise, if you want to change rows, you can also "[Parallel1; Matrix2]".
6. Multiplication for Each Element in a Matrix.
Usually, "Parallel1*Parallel2" performs matrix multiplication. However, if you want to multiply the two matrices by the elements, you can put . in front of the operator. In other words, it is expressed in the form of "Parallel1.*Parallel2". This can be useful in processing extracted data. The same goes for division.
7. Inverse Matrix
It can be obtained in one second by the Inv() function.
8. Flip the Order of Elements in a Matrix
To rearrange the matrix upside down, you can use a function called flip().
I'll add more if I think of anything else later.
'유용한 지식 > Matlab' 카테고리의 다른 글
Tips for Matlab Equation (0) | 2020.09.24 |
---|---|
Get Matlab Excel Data | xlsread function (0) | 2020.09.24 |
Using the Matlab 'for Statement' | Loop Statement (0) | 2020.09.24 |
Using Matlab 'if Statement' | Assumption Statement (0) | 2020.09.24 |
Matlab Graph Axis Tick | Plot Advanced Edit1 (0) | 2020.09.24 |
댓글