change binary string to decimal

1 次查看(过去 30 天)
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?

采纳的回答

Andrei Bobrov
Andrei Bobrov 2012-4-6
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).';

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numeric Types 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by