Matlab---data type _matlab

Source: Internet
Author: User

1. Get data Type list available commands doc datatypes

Integral type data
2.Matlab by default, all values are stored as double-precision floating-point numbers (double), and the integer data provided by MATLAB has eight types, namely (8,16,32,64 bit) * (signed number, unsigned number).

3. No operations can be performed between different integral types of data. That is, 8-bit integer data cannot be calculated with 32-bit integer data.

4. Integer data can be numerically calculated with a double-precision scalar, the result is an integer, the precision of floating-point operations is maintained during the operation, and the result is converted to an integral type (converted by rounding). However, integer data cannot be calculated with a non-double-precision array.

5. After the integer data overflow, maintain the maximum value of the integer data type, the overflow remains the largest, and the underflow remains the minimum value.

6. Four kinds of rounding functions ceil, fix, Floor, round (upper, middle, down, rounded).

7.mod is modulus, REM is the remainder, the calling format is mod (x,y) and REM (X,y). Although the two are much the same in many numerical computations, the essential concepts of the two are different, so they differ in some small places.
A.Y = 0 o'clock, mod (x,y) =x, REM (x,y) =nan
B. When y!=0 and X!=y, mod (x,y) and y are the same number, while REM (x,y) and X are the same.

Floating-point data
8. Floating-point data includes single-precision (single 32-order 8-bit) and double (64-order 11-bit), with the default double format, which can be cast between the two formats.

9. Floating-point data manipulation functions: Isfloat, Double, single, EPS, format, Realmax, Realmin

10.eps EPS (a) is the distance between |a| and the smallest floating-point number greater than |a|, and the smaller the distance, the higher the precision. Default A=1. Eps=eps (1), is 1 precision. That is to say, Matlab cannot represent the number between 1 and 1+eps, these numbers will be rounded to 1 or 1+eps.
We know that floating point numbers are discrete, finite, and that the spacing is uneven. We can say what the number is next to a number, and the distance between them reflects its precision. The closer you are to 0, the more dense the number and numbers, the higher the precision.
For floating-point numbers, the closer you are to 0, the higher the precision. So the 2 accuracy is lower than the 1 precision. ' 0 is the highest precision, which means that EPS (0) is the smallest positive number that can be represented by MATLAB. Search it and EPS compared to more than 300 orders of magnitude, EPS and it compared to the large astronomical.

Plural
11. The complex number is the basic unit of MATLAB, I is the basic imaginary unit, in MATLAB can also be used to express basic imaginary units.

12. There are two main ways to construct complex numbers in MATLAB: direct generation and generation with function complex.
The complex number with imaginary part 0 can not be generated by direct generation method, and the complex number that generates imaginary part 0 can only be generated by complex function.

13. Functions of complex numbers: Isreal, real, imag, ABS, Angle, CONJ.

String
In 14.Matlab, each character is represented by an ASCII code, which uses a 16-bit Unicode encoding to occupy two bytes of memory. Multiple strings can form an array of strings, but each string must be of the same length, with a different space.

15.Matlab mainly provides three ways to create a string.
A. Enter the desired content directly in a pair of single quotes, and the single quotation marks must be entered in the English state. When you want to create a string that contains single quotes in English state, each single quote character is represented by a "2 consecutive single quote character."
B. Using the Char function, the char function is automatically replenished without regard to the inconsistency of string lengths.
C. Generating strings using character arrays

16.SPRINTF generates a formatted string.

Cell arrays
17. A cellular array can store different types of data in the same matrix (known as a generalized matrix). A cell array is composed of a series of cells. Each cell stores data as a separate storage unit, and they can hold different types of data. This provides a great convenience and flexibility to the user's programming.

18. Two ways to create a cell array:
A. Direct definition with assignment statements
B. The cell function allocates storage space beforehand, and then assigns each element of the cell.

19. Users can access elements in the cell array in two ways, "()" and "{}", and the results returned by the two methods are different.
C (m,n) returns the cell in the position of cell array C (M,N), which cannot modify the value of the cell, and C{m,n} returns the data in the cell in the cell array C (m,n) position, which modifies the cell value.

20. Cell array related operation function: Iscell, Celldisp, Cellstr, Cellplot

21.cellplot displays a graphical description of the cell array. Fill color According to data type, data type is double-precision floating-point type (red), character type (orange), sparse matrix (yellow), structure array (green), others (blue)

Array of structures
22. There are two ways to create an array of structures:
A. Using the (.) operator to create,
B. Creating an array of structures using the struct function
You can use the above methods to create arrays of high dimensional structures

23. Structure Array functions: Isstruct, Deal, Isfield, GetField, SetField, Rmfield, OrderFields, FieldNames

The structural body and the cell can be converted to each other.

function handle
24. A function handle is a special type of data that provides a method of indirectly calling a function, similar to the C-language function pointer.
The function handle contains the path to the function, the function name, the type, and the possible overloaded method, which must be created by a specific definition
Syntax format is Fhandle = @functionname
FunctionName is a function name or M filename, Fhandle is a function handle

25. Use function functions to get the information of the function handle.

Conversions between different data types
26.str2double converts a string (a string of numbers, which cannot be) to a number (scalar), Str2Num converts a string array to a matrix.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.