Binary to Decimal Conversion in MATLAB

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.