Binary to Decimal Conversion in MATLAB
Advertisement
This page provides MATLAB source code for binary to decimal conversion using the bin2dec function.
bin2dec MATLAB Function
The bin2dec MATLAB function converts a binary string input into its equivalent decimal value. The syntax is as follows:
output = bin2dec(input)
Where:
input: A string representing a binary number.output: The decimal equivalent of the binary string.
Example
Here’s an example demonstrating the usage of the bin2dec function:
input = '00101000';
output = bin2dec(input);
% The output will be 40
In this example, the binary string ‘00101000’ is converted to its decimal equivalent, which is 40.
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
