change binary string to decimal

3 views (last 30 days)
GGG =
0 1 0 0 0 1 0 0 0 0
0 1 0 0 0 1 0 0 0 0
1 1 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 1 0 1 0 0 0 1
0 0 1 0 0 1 0 0 0 0
0 0 0 1 0 0 0 0 0 0
0 1 0 1 0 0 0 0 0 1
1 0 0 1 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 1
I hve this binary string. I need to convert this to decimal. How can I do this?

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 6 Apr 2012
try use this is code:
GGG =[ 0 1 0 0 0 1 0 0 0 0
0 1 0 0 0 1 0 0 0 0
1 1 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 1 0 1 0 0 0 1
0 0 1 0 0 1 0 0 0 0
0 0 0 1 0 0 0 0 0 0
0 1 0 1 0 0 0 0 0 1
1 0 0 1 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 1]
out = GGG*2.^(size(GGG,2)-1:-1:0).';

More Answers (0)

Categories

Find more on Numeric Types in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!