Code covered by the BSD License  

Highlights from
MATLAB Support Package for Velleman K8055/VM110 Experiment Board

MATLAB Support Package for Velleman K8055/VM110 Experiment Board

by

 

MATLAB library for communicating with a Velleman K8055/VM110 USB Experiment Interface Board

vellboard.util.binvec2int(V)
function result = binvec2int(V)
% binvec2int: converts a 1xn binary vector into a decimal integer
%
% ans = binvec2int(V)
%   Takes the row (ie. 1xn) binary vector V and converts it to decimal. 
%   Uses little endian, so V(1) is the ones place. In other words, each 
%   entry V(i) is effectively multiplied by 2^(i-1) and summed to get the 
%   result.

%   Copyright 2011 The MathWorks, Inc.

validateattributes(V,{'numeric'},{'binary','row'});

result = 0;

for i = 1:size(V,2)
    if V(i)
        result = bitset(result,i);
    end
end

end

Contact us