matlab如何查数据类型,MATLAB数据类型
MATLAB数据类型
MATLAB 并不需要任何类型的声明或维度报表。 MATLAB 每当遇到⼀个新的变量名称,创建变量,并分配适当的内存空间。
如果变量已经存在,则MATLAB替换以新的内容的原始内容,并分配新的存储空间,在必要的情况下。
例如,
Total=42
上述语句创建了⼀个名为“Total” 的 1-1 矩阵存储值42。
MATLAB中可⽤的数据类型
MATLAB 提供15个基本数据类型。每种数据类型的数据存储在矩阵或阵列的形式。这个矩阵的⼤⼩或阵列是⼀个最低 0-0,这可以长⼤为任何规模⼤⼩的矩阵或数组。
下表显⽰了在 MATLAB 中最常⽤的数据类型:
数据类型
描述
int8
8-bit signed integer
uint8
8-bit unsigned integer
int16
16-bit signed integer
uint16
16-bit unsigned integer
int32
耶稣会
32-bit signed integer
uint32
32-bit unsigned integer
int64
64-bit signed integer
uint64
64-bit unsigned integer
single
single precision numerical data
double
double precision numerical data
logical values of 1 or 0, reprent true and fal respectively
char
character data (strings are stored as vector of characters)
cell array
拉杆箱什么牌子好array of indexed cells, each capable of storing an array of a different dimension and data type
structure
C-like structures, each structure having named fields capable of storing an array of a different dimension and data type function handle
yiibaier to a function
ur class
objects constructed from a ur-defined class
java class
objects constructed from a Java class
例⼦
创建⼀个脚本⽂件,⽤下⾯的代码:
str='Hello World!'n=2345d=double(n)un=uint32(789.50)rn=5678.92347c=int32(rn)
上⾯的代码编译和执⾏时,它会产⽣以下结果:
str =
Hello World!
n =
2345
d =
2345
un =
790
rn =
5.6789e+03
c =
5679
数据类型转换
MATLAB 提供各种函数,⽤于从⼀种数据类型转换到另⼀种。下表显⽰的数据类型转换函数:
函数
⽬的/作⽤
Convert to character array (string)
int2str
Convert integer data to string
mat2str
Convert matrix to string
num2str
Convert number to string
str2double
Convert string to double-precision value
str2num
Convert string to number
native2unicode
Convert numeric bytes to Unicode characters
unicode2native
Convert Unicode characters to numeric bytes
ba2dec
Convert ba N number string to decimal number
bin2dec
Convert binary number string to decimal number
dec2ba
Convert decimal to ba N number in string
dec2bin
c蛋白Convert decimal to binary number in string
dec2hex
Convert decimal to hexadecimal number in string
hex2dec
Convert hexadecimal number string to decimal number
hex2num
Convert hexadecimal number string to double-precision number num2hex
Convert singles and doubles to IEEE hexadecimal strings
cell2mat
Convert cell array to numeric array
Convert cell array to structure array
cellstr
Create cell array of strings from character array
mat2cell
Convert array to cell array with potentially different sized cells num2cell
Convert array to cell array with consistently sized cells
struct2cell
Convert structure to cell array
测定的数据类型
MATLAB 提供各种函数标识数据类型的变量。
幼儿园小班学期计划下表提供了确定⼀个变量的数据类型的函数:
函数
⽬的/作⽤
若的意思
is
Detect state
isa
管理状况
Determine if input is object of specified class
iscell
Determine whether input is cell array
iscellstr
Determine whether input is cell array of strings
ischar
Determine whether item is character array
isfield
Determine whether input is structure array field
isfloat
Determine if input is floating-yiibai array
ishghandle
True for Handle Graphics object handles
isinteger
Determine if input is integer array
isjava
islogical
Determine if input is logical array
isnumeric
Determine if input is numeric array
淡红色isobject
Determine if input is MATLAB object
isreal
Check if input is real array
isscalar
Determine whether input is scalar
isstr
Determine whether input is character array
isstruct
Determine whether input is structure array
isvector
Determine whether input is vector
class
Determine class of object
validateattributes
城镇化建设
Check validity of array
whos
List variables in workspace, with sizes and types
例⼦
创建⼀个脚本⽂件,⽤下⾯的代码:
x=3isinteger(x)isfloat(x)isvector(x)isscalar(x)isnumeric(x)x=23.54isinteger(x)isfloat(x)isvector(x)isscalar(x)isnumeric(x)x= [123]isinteger(x)isfloat(x)isvector(x)isscalar(x)x='Hello'isinteger(x)isfloat(x)isvector(x)isscalar(x)isnumeric(x)
当运⾏该⽂件,它会产⽣以下结果:
x =
3
ans =
ans =
1