Code covered by the BSD License  

Highlights from
Matlab LibTiePie 0.4.3 instrument driver for Handyscope HS5

Matlab LibTiePie 0.4.3 instrument driver for Handyscope HS5

by

 

03 Oct 2013 (Updated )

MatlabLibTiePie : TiePie engineering's instrument library for Matlab 7.6 = 2008a and higher.

LibTiePie.BitMask2Array( nMask )
% BitMask2Array extracts from an integer the values of the separate bits.
% Example:
%   BitMaskToArray( 3 ) is [ 1 , 2 ]
%   BitMaskToArray( 5 ) is [ 1 , 4 ]
%
% (c) 2012-2013 TiePie engineering.

function arBitValues = BitMask2Array( nMask )
  arBitValues = [];
  %arOnes = dec2binvec( nMask ); % Copied the next two lines from dec2binvec because it is not always available:
  out = dec2bin( nMask );
  arOnes = logical( str2num( [ fliplr( out ) ; blanks( length( out ) ) ]' )' );

  for k = 1 : length( arOnes )
    if arOnes( k )
      arBitValues = [ arBitValues , 2^( k - 1 ) ];
    end
  end;
end

Contact us