Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does matlab define a matrix

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how matlab defines the matrix. I hope you will get something after reading this article. Let's discuss it together.

Numerical calculation of matlab Matrix

1. Definition of matrix

The operation object of Matlab is matrix.

Definition matrix: direct input method

A = [1 23; 4 56; 7 8 9]

The matrix is enclosed in square brackets "[]"

Mat = [element]

Elements in the same row of the matrix are separated by spaces or commas

Mat1 = [1 / 2 / 3]; mat2 = [1 / 2 / 2 / 3]

Matrix rows are separated by semicolons

Mat3 = [1 23; 4, 5, 6]

In the direct input method, the semicolon can be replaced by enter.

Mat4 = [1 234 5 6]

two。 Matrix assignment operation

-Matrix An is a 1-2 matrix, the first element 1, the second element 2

A (1) = 1 * * A (2) = 2

A large matrix can take a small matrix as its element.

A = [A; 3 4]

3. Matrix element extraction reference operation

A reference to a single element; using parentheses and the location of the element (subscript) A (1)% to refer to the first element A (I): the first element An in the vector x A (iQuery j): row I in matrix A, reference to multiple elements in column j: special use of colons a:b:c% produces a vector consisting of an isometric sequence; an is the first term, b is the tolerance, and c determines the last term If bounded 1, then b can be omitted. The reference A (iRV j, mRO n)% of matrix elements represents a submatrix consisting of elements on the crossing lines of rows I to j and columns m to n of matrix A. % can use colons to extract the entire row or column of the matrix. > > A (1,:) > A (:, 1:3) > > A (:,:)

4. Establish the matrix to advance

Use functions to build numerical matrices: MATLAB provides many functions for generating and manipulating matrices, which can be used to build matrices. For example: reshape function and diag function and so on. The reshape function is used to establish a numerical matrix. The diag function is used to generate a diagonal matrix.

Use M file to build matrix: for larger and more complex matrices, you can create a special M file for it. The steps are as follows:

Step 1: use the editor to enter the contents of the file.

Step 2: save the input in plain text (set the file name to mymatrix.m).

Step 3: type mymatrix in the MATLAB command window and a matrix called AM is automatically created for later display and invocation.

Use M file to build matrix: for larger and more complex matrices, it can specifically create an M file. The steps are as follows:

Step 1: use the editor to enter the contents of the file.

Step 2: save the input in plain text (set the file name to mymatrix.m).

Step 3: type mymatrix in the MATLAB command window and a matrix called AM is automatically created for later display and invocation.

The basic operation of matrix

(1) Matrix transpose (2) Matrix addition and subtraction (3) Matrix multiplication (4) Matrix Division A\ b=inv (A) * b (5) the multiplier a ^ 2 * * matrix function * *

() 5. Establish the function of a matrix

Eye (size (A)) produces a unit matrix of the same order as the A matrix zeros (mmaginn) generates 0 matrix ones (mmaginn) produces a unitary matrix rand (menern) produces a matrix Size (a) that produces random elements and returns a vector containing two elements. Length (a) returns the length of the vector.

6. Array operation

(1) addition and subtraction of arrays (2) multiplication and division of arrays (3) multipliers of arrays

7. Give an example

1. Determinant calculation

Det ([1 2; 3 4])

2. solve the system of linear equations

X = A\ b

3. Solving the eigenvalue problem

Eig (A) after reading this article, I believe you have some understanding of "how matlab defines matrix". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 283

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report