i have a large matrix whose elements is 1 and 0; how to conver each row to decimal ,like bin2dec

i do it like this
if true
rownum = size(Qbinnum,1);
for i = 1:rownum
cgroup(i)=bin2dec(num2str(Qbinnum(i,:)));
end
end
as the matrix is big, so it takes a lot of seconds ,any way easier ,less time ways?

2 件のコメント

Rick Rosson
Rick Rosson 2014 年 9 月 15 日
How many columns are there in Qbinnum?
Roger
Roger 2014 年 9 月 15 日
it is a variable

サインインしてコメントする。

 採用された回答

N = size(Qbinnum,2);
k = ((N-1):-1:0)';
v = 2.^k;
cgroup = Qbinnum*v;

その他の回答 (1 件)

What does this say
whos Qbinnum

1 件のコメント

Roger
Roger 2014 年 9 月 15 日
Qbinnum is a big size matrix ,like this [1 0 0 1 1 1; 1 0 0 1 1 1; 1 0 0 1 1 0; 1 0 1 1 1 1; ... 1 1 1 1 1 1; 0 1 0 1 0 0 ]

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

タグ

質問済み:

2014 年 9 月 15 日

コメント済み:

2014 年 9 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by