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

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

采纳的回答

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

更多回答(1 个)

Image Analyst
Image Analyst 2014-9-15
What does this say
whos Qbinnum

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by