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

1 Ansicht (letzte 30 Tage)
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?

Akzeptierte Antwort

Rick Rosson
Rick Rosson am 15 Sep. 2014
N = size(Qbinnum,2);
k = ((N-1):-1:0)';
v = 2.^k;
cgroup = Qbinnum*v;

Weitere Antworten (1)

Image Analyst
Image Analyst am 15 Sep. 2014
What does this say
whos Qbinnum
  1 Kommentar
Roger
Roger am 15 Sep. 2014
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 ]

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by