This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Data Type Conversion

Converting between numeric arrays, character arrays, cell arrays, structures, or tables


charCharacter array
cellstrConvert to cell array of character vectors
int2strConvert integers to characters
mat2strConvert matrix to characters
num2strConvert numbers to character array
str2doubleConvert string to double precision value
str2numConvert character array to numeric array
native2unicodeConvert numeric bytes to Unicode character representation
unicode2nativeConvert Unicode character representation to numeric bytes
base2decConvert text representing number in base N to decimal number
bin2decConvert text representation of binary number to decimal number
dec2baseConvert decimal number to character vector representing base N number
dec2binConvert decimal number to character vector representing binary number
dec2hexConvert decimal number to character vector representing hexadecimal number
hex2decConvert text representation of hexadecimal number to decimal number
hex2numConvert IEEE hexadecimal string to double-precision number
num2hexConvert singles and doubles to IEEE hexadecimal strings
table2arrayConvert table to homogeneous array
table2cellConvert table to cell array
table2structConvert table to structure array
array2tableConvert homogeneous array to table
cell2tableConvert cell array to table
struct2tableConvert structure array to table
cell2matConvert cell array to ordinary array of the underlying data type
cell2structConvert cell array to structure array
mat2cellConvert array to cell array whose cells contain subarrays
num2cellConvert array to cell array with consistently sized cells
struct2cellConvert structure to cell array

Examples and How To

Convert from Character Arrays to Numeric Values

This summary details how to convert character arrays to numeric values.

Convert from Numeric Values to Character Array

This summary details how to convert numeric values to character arrays.


Valid Combinations of Unlike Classes

If you include elements of unlike classes in a matrix, MATLAB® converts some elements so that all elements of the resulting matrix are of the same type. Data type conversion is done with respect to a preset precedence of classes.