본문 바로가기
유용한 지식/Matlab

Tips for Matlab Matrix

by 그래도_明 2020. 9. 24.

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.

<A transferred to A' >

 

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.

<zeros and ones function results>

 

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.

<Results of length and size functions>

 

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 ': '.

<Results of Matrix Extraction>

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]".

<Emerging Matrices Results >

 

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.

<Matrix Multiplication and Division Results>

7. Inverse Matrix

It can be obtained in one second by the Inv() function.

<Reverse matrix calculation results>

 

8. Flip the Order of Elements in a Matrix

To rearrange the matrix upside down, you can use a function called flip().

<The function flip>

 

 

I'll add more if I think of anything else later.

반응형

댓글