Decimal to Base-N Conversion in MATLAB

This page provides MATLAB source code for converting a decimal number to a base-N number string. This functionality is similar to the dec2base MATLAB function. The dec2base function converts a decimal integer to a string representation in a specified base ‘b’.

MATLAB Code Example: dec2base Functionality

>> output = dec2base(25, 3)
output =
    '221'

In this example, the decimal number 25 is converted to its base-3 representation, resulting in the string ‘221’.