Decimal to Binary Conversion using MATLAB
Advertisement
This document provides MATLAB source code for converting decimal numbers to their binary equivalents. Specifically, it covers the dec2bin MATLAB function.
dec2bin Function
The dec2bin function takes a non-negative decimal integer as input and returns its binary representation as a string.
Syntax:
output = dec2bin(input);
Description:
The dec2bin function converts a non-negative decimal integer number to its binary string equivalent. The integer number argument should be less than 252.
Example:
input = 250;
output = dec2bin(input);
% Output will be: output = '11111010'
Explore MATLAB Data Types, Strings & Conversions
- Binary to Decimal Conversion in MATLAB
- Binary to Hex Conversion in MATLAB
- Decimal to Base-N Conversion in MATLAB
- Decimal to Binary Conversion in MATLAB
- Decimal to Hexadecimal Conversion in MATLAB (dec2hex)
- Hex to Binary Conversion in MATLAB
- Hexadecimal String to Double Conversion in MATLAB
- Number to Hexadecimal String Conversion in MATLAB
- Number to String Conversion in MATLAB (num2str)
- String to Double Conversion in MATLAB
- String to Number Conversion in MATLAB (str2num)
- MATLAB Matrix to String (mat2str)
- Base-N Number String to Decimal in MATLAB
