Matlab数据类型及转换(Matlab data type and conversion)
Matlab数据类型及转换(Matlab data type and conversion)
Matlab data type and conversion (2011-05-1615:10:59)
Label: miscellaneous: memos
In Matlab, there are 15 basic data types, mainly integer, floating point, logic, character, date and time, structure array, cell array, and function handle.
1. Integral type: (int8; uint8; int16; uint16; int32; uint32; int64; uint64) returns the maximum and minimum value of the class integer by intmax (class) and intmin (class) function, such as intmax (' int8 ') = 127;
(1)
Floating-point Numbers: REALMAX (' double ') and REALMAX (' single ') respectively return the maximum value of double-precision floating-point and single-precision floating-point, and REALMIN (' double ') and REALMIN (' single ') respectively return the minimum values of double-precision floating-point and single-precision floating-point.
3. Logic:
Logical: the next example is the application of Logical index in matrix operation, setting the element with greater than 0.5 in the 5 * 5 matrix to 0:
A = rand (5);
A (A > 0.5) = 0;
Character: (char)
Use single quotation marks for input characters in Matlab. The string is stored as an array of characters, each of which occupies an ASCII character. The date character: DateString = '9/16/2001' is actually a row of 9 column vectors. The length of the row string that constitutes a matrix or vector must be the same. You can use the char function to build the array of characters, using the strcat function to connect the characters.
For example, the command name = [' ABC '; 'abcd'] would trigger error warning, because of the length of the two strings differ, at this time to cobble together a null character such as: name = [' ABC '; 'abcd'], a more simple solution is to use char function: char (' ABC ', 'abcd'), automatic filling and the length and width of the characters to make Matlab are equal, so the string matrix column weft is always equal to the longest string of characters.
For example, size (char (' ABC ', 'abcd')) returns th