Fortune Telling Collection - Comprehensive fortune-telling - What are the commands commonly used in matlab?

What are the commands commonly used in matlab?

Matlab command

First, common object operations: in addition to the common function keys of general windows windows.

1、! Dir can view files in the current working directory. ! Director & can view it in dos state.

2. Who can view the variable name of the current workspace and who can view the detailed information of the variable name.

3. Function keys:

Function key shortcut description

Press Ctrl+P to return to the previous line of input.

Press Ctrl+N down to return to the next line of input.

Direction left key Ctrl+B cursor moves backward by one character.

Right arrow key Ctrl+F cursor moves forward one character.

Ctrl+ right arrow key Ctrl+R cursor moves one character to the right.

Ctrl+ direction left key Ctrl+L cursor moves one character to the left.

Home Ctrl+ cursor moves to the beginning of the line.

End Ctrl+E cursor moves to the end of the line.

Esc Ctrl+U clears a line.

Clear the character where the cursor is located.

Backspace Ctrl+H deletes the previous character of the cursor.

Ctrl+K delete to end of line

Ctrl+C interrupts the executing command.

4.clc can command the contents displayed in the window, but it does not clear the workspace.

Second, the function and operation

1, operator:

+:addition,-:subtraction, *: multiplication,/:division, \: left division: power,': complex number * * * yoke transposition, (): calculate the operation order.

2, commonly used menu:

Sin () sine (variable is radian)

Cot () cotangent (variable is radian)

Sind () sine (variable is degree)

Cotd () cotangent (variable is degree)

Asin () Arcsine (Return radian)

Acot () inverse cotangent (return radian)

Asind () arcsine (degree of return)

Acotd () inverse cotangent (degree of return)

Cos () cosine (variable is radian)

Exponential index

Cosine function (variable is degree)

Log () logarithm

Acos () cosine value (returns radian)

Log 10 () uses 10 as the base logarithm.

Cosine value of Acosd () (degree of return)

Sqrt () prescription

Tangent (variable is radian)

Realsqrt () returns a non-negative root.

Tangent (variable is degree)

Abs () takes the absolute value.

Atan () arctangent (return radian)

Angle () returns the phase angle of a complex number.

Atand () arctangent (returns degrees)

Mod(x, y) returns the remainder of x/y.

Sum () vector element sum

3. the 3.rest function can be obtained by using the help elfun and help specfun commands.

4. Values of common constants:

pi 3. 14 15926……

Realmin minimum floating point number, 2- 1022

Imaginary unit

Realmax maximum floating-point number, (2-EPS) 2 1022.

Imaginary unit

Inf infinite value

Eps floating point relative longitude = 2-52

NaN null value

III. Arrays and matrices:

1, the method of constructing an array: incremental sum linspace(first, last, num)first and last are the starting and ending numbers, and num is the number of required array elements.

2. Method of constructing the matrix: You can directly input the array with [], or you can generate the matrix with the following function.

Ones () creates a matrix containing all elements of 1, in which the dimension can be represented by 1, 2.

Zeros () creates a matrix with all elements of 0.

Eye () creates a matrix with diagonal elements of 1 and other elements of 0.

Diag () creates a diagonal matrix from a vector, that is, the elements of the vector are diagonal elements.

Magic () creates a Rubik's cube matrix.

Rand () creates a random matrix and obeys uniform distribution.

Randn () creates a random matrix and obeys normal distribution.

Randperm () creates a random row vector.

Horcat C=[A, B], horizontal polymerization matrix, cat( 1, a, b) is also acceptable.

vercat C =[A; B], vertical aggregation matrix, or cat(2, a, b).

Repmat(M, v, h) aggregates the matrix m for v times in the vertical direction and h times in the horizontal direction.

Blkdiag(A, b) creates a block diagonal matrix with a, and b as blocks.

Length returns the length of the longest dimension of a matrix.

Ndims returns dimensions.

Numel returns the number of matrix elements.

Size returns the length of each dimension, [rows, cols]=size(A)

Reshape reshapes the matrix, shape(A, 2, 6), and changes A into a 2×6 matrix, arranged in columns.

Rot90 rotates the matrix 90 degrees counterclockwise.

Fliplr flips the matrix along the vertical axis.

Flipud flips the matrix along the horizontal axis.

Transpose the matrix along the main diagonal.

The Ctranspose transpose matrix can also be a' or a.', which is different only when the matrix is a complex matrix.

Inverse matrix of inventory matrix

Determinant value of det matrix

Sum of diagonal elements of trace matrix

Norm matrix or vector norm, norm (a, 1), norm (a, INF) ...

Maximum norm vector of norm estimation matrix

Coleski decomposition of chol matrix

Cholinc incomplete cholesky decomposition

Lu Lu decomposition

LUinc incomplete Lu decomposition

Qr orthogonal decomposition

If kron(A, B) A is m×n and b is p×q, a matrix of mp×nq will be generated, and each element of A will be multiplied by b, occupying a space of p×q size.

Rank finding the thorn of matrix

Finding pseudo-inverse matrix with pinv

A p operates on a.

A.^P operates on every element in a.

Fourthly, numerical calculation.

1, solving linear equations

(1) the solution of ax = b can be found from x = a \ b, and the solution of XA=B can be found from x = a/b if a is a matrix of m×n, when m = n, m.

(2) ax = b, a = l× u, [L, U]=lu(A), X=U\(L\b), that is, it is solved by lu decomposition.

(3)QR (orthogonal) decomposition represents a matrix as the product of an orthogonal matrix and an upper triangular matrix, where a = q× r [q, r] = CHOL (a) and x = q \ (u \ b).

(4)cholesky decomposition is similar.

2. Eigenvalue

D = EIG (a) returns the matrix [V, D]=eig(A) of all eigenvalues of A, and the eigenvector matrix is also returned.

3.A = u× s× ut, [U, S]=schur(A), where the diagonal element of s is the eigenvalue of a. ..

4. Polynomials in 4.Matlab are represented by vectors, and the specific operation functions are as follows:

Multiplication of conv polynomials

Division of deconv polynomial, a, b = Deconv (s), returns quotient and remainder.

Poly finds the coefficients of a polynomial (finding the coefficients of a polynomial from a known root)

Finding the eigenvalue of polynomial by polynomial

Curve fitting of Polyfit(x, y, n) polynomial, where x and y are fitting vectors and n is the order of fitting polynomial.

Polyder finds the first derivative of polynomial, and polyder(a, b) returns the derivative of ab.

[a, b] = poly der (a, b) gives the derivative of a/b.

Multifactorial polynomial integral

Polyval finds the value of polynomial

Polyvalm takes matrix as a variable to find the value of polynomial.

Fractional expansion of remaining part

Find the roots of a polynomial (return a vector consisting of all roots)

Note: ploy(A) is used to find the characteristic polynomial of the matrix, and then the root is found, which is the eigenvalue of the matrix.

5. Interpolation functions commonly used for interpolation are as follows:

Griddata data grid composite surface fitting

Composite Hypersurface Fitting of Griddata3 3D Data Grid

Interp 1 one-dimensional interpolation (yi = interp 1 (x, y,' method') method = nearest/linear/spline /PC hip/ cube.

Interp2 two-dimensional interpolation zi = interp 1 (x, y, z, yi' method'), bilinear.

Interp3 3 d interpolation

Interpft uses fast Fourier transform to carry out one-dimensional interpolation and assist fft.

Mkpp uses piecewise polynomials

Spline cubic spline interpolation

Piecewise hermit interpolation

6. Solving the maximum value of the function

Fminbnd('f' f', x 1, x2, optiset (,) find the minimum value of f between x 1 and x2. The Optiset option can have Display +“ITER”/ Close/Final, which respectively means to display the calculation process/not display/only display the final result. Find the minimum value of multivariate function. Fzero('f' f', x 1) finds the zero point of a unary function. X 1 is the starting point. You can also use the above options.

Verb (abbreviation for verb) image drawing:

1, basic drawing function

Plot draws a two-dimensional linear graph and two coordinate axes

Plot3 draws a three-dimensional linear graph and two coordinate axes

Fplot draws an image of the function at a specified interval. Fplot('f' f', area, line type, color)

Loglog draws a logarithmic graph and two coordinate axes (both logarithmic coordinates) semilogx draws a semi-logarithmic coordinate graph.

Semilogy draws semi-logarithmic coordinates.

2. Linetype: color linetype

Y yellow. Dotted line v down arrow

G green. Combination > right arrow

B the blue+dot is a plus sign.