# Base Transformations In MatLab® With Different Commands

Base transformations are a very important topic in engineering calculus. Matlab® provides various kinds of commands to making base transformations easy. Here, we will show you all of these base transformation commands in Matlab® with very basic illustrative examples that are executed in the Matlab® Command Window.

On this post

## dec2bin() Command In MatLab®

``````>> a= dec2bin(9)

a =

'1001'

>> ``````

The use of the ‘dec2bin()’ command in Matlab® is very simple. dec2bin() command converts the number which is a decimal number, to a base two number. Take a look at the example above to understand the syntax of this command.

## bin2dec() Command In Matlab®

``````>> bin2dec('1100100')

ans =

100

>> ``````

As you understand from the syntax of the bin2dec() command, it converts the number in base two, into decimal numbers as you see in the example above.

## dec2hex() Command In MatLab®

``````>> dec2hex(15)

ans =

'F'

>> ``````

## hex2dec() Command In Matlab®

``````>> hex2dec('2D')

ans =

45

>> ``````

As you understand from the syntax of the bin2dec() command, it converts the number in base two, into decimal numbers as you see in the example above.

YOU CAN LEARN MatLab® IN MECHANICAL BASE; Click And Start To Learn MatLab®!

## dec2base() Command In MatLab®

``````>> dec2base(250,8)

ans =

'372'

>> ``````

dec2base command in Matlab® converts the first number that typed inside brackets which is a decimal number, into the base which is the second number in the dec2base() command.

If you take a look at the example above that executed in the Matlab® command window, integer 250 is converted to eight bases.

## base2dec() Command In MatLab®

``````>> base2dec('360210',7)

ans =

64932

>> ``````

In base2dec() command in Matlab®, the first number which is in the second number base is converted to a decimal number.

In the example above, the number 360210 which is in the 7 bases, is converted to a decimal number in answer.

## Conclusion

As you see above, base transformations are very easy and useful in Matlab®.

Do not forget to leave your comments and questions below about the use of base conversion commands in Matlab® below. If you want further coding examples about base transformation commands in Matlab, inform us in the comments.