Home > vbmeg > functions > device > trigger_timing > vb_bit_ptn_start.m

vb_bit_ptn_start

PURPOSE ^

Find time points that signal changes to the given integer bit pattern

SYNOPSIS ^

function ix = vb_bit_ptn_start(y,status,t_stay)

DESCRIPTION ^

 Find time points that signal changes to the given integer bit pattern
 only specified bits are examined and other bits are ignored 
 by taking bitwise AND
     ix = vb_bit_ptn_start(y,status)
     ix = vb_bit_ptn_start(y,status,t_stay)
 y : event signal
 status : integer defined by bit pattern
        = 2^n : correspond to check n-th bit
 t_stay : minimum length to stay the specified value [default = 10]
          'y' should be stay at the value 'status' for more than t_stay
 
 ix : index corresponding to the start point 
      'y' changes to 'status' from other value
      
 2009-6-11 Masa-aki Sato
 2012-1-8  Masa-aki Sato Bug fix

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    ix = vb_bit_ptn_start(y,status,t_stay)
0002 % Find time points that signal changes to the given integer bit pattern
0003 % only specified bits are examined and other bits are ignored
0004 % by taking bitwise AND
0005 %     ix = vb_bit_ptn_start(y,status)
0006 %     ix = vb_bit_ptn_start(y,status,t_stay)
0007 % y : event signal
0008 % status : integer defined by bit pattern
0009 %        = 2^n : correspond to check n-th bit
0010 % t_stay : minimum length to stay the specified value [default = 10]
0011 %          'y' should be stay at the value 'status' for more than t_stay
0012 %
0013 % ix : index corresponding to the start point
0014 %      'y' changes to 'status' from other value
0015 %
0016 % 2009-6-11 Masa-aki Sato
0017 % 2012-1-8  Masa-aki Sato Bug fix
0018 %
0019 % Copyright (C) 2011, ATR All Rights Reserved.
0020 % License : New BSD License(see VBMEG_LICENSE.txt)
0021 
0022 if nargin < 3, t_stay = 10; end;
0023 
0024 T = length(y);
0025 
0026 % take bitwise AND to ignore irrelevant bit
0027 y = bitand(y,status);
0028 
0029 flg = ones(1,T-t_stay);
0030 tt  = 1:T-t_stay;
0031 
0032 % 'y' is not 'status' value beforehand
0033 flg = flg .* (y(tt) ~= status);
0034 
0035 % 'y' should be stay at the value 'status' for more than t_stay
0036 for t=1:t_stay
0037     flg = flg .* (y(tt + t) == status);
0038 end
0039 
0040 ix = find(flg == 1);
0041 
0042 return

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005