dec2hex

Converts a non-negative integer, matrix or cell array, n, to it's hexadecimal equivalent.

Syntax

R = dec2hex(n)

R = dec2hex(n, len)

Inputs

n
Finite, non-negative integer, matrix or cell array of finite, non-negative integers.
Type: cell | mat | int
len (optional)
Argument which can specify the minimum length of each element if n is a matrix or a cell array. Valid values are finite, positive integers.
Type: Finite, positive integer

Outputs

R
If n is a matrix or cell array, R, will be a string array with one row for each element. Every element will be the same width as the widest element, with leading zeros padding the value.
Type: matrix | string

Examples

Integer to hexadecimal example:
R = dec2hex(9876543210)
R = 24CB016EA
Matrix to hexadecimal example:
R = dec2hex([97, 65, 1])
R =
61
41
01
Cell array, with minimum output length specified, to hexadecimal example:
R = dec2hex({700, 555, 1}, 8)
R =
000002BC
0000022B
00000001