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

vb_bit_ptn_end

PURPOSE ^

Find time points that signal differ from the given integer bit pattern

SYNOPSIS ^

function ix = vb_bit_ptn_end(y,status,t_stay)

DESCRIPTION ^

 Find time points that signal differ from the given integer bit pattern
 only specified bits are examined and other bits are ignored 
 by taking bitwise AND
     ix = vb_bit_ptn_end(y,status)
     ix = vb_bit_ptn_end(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
          Then, 'y' changes to other value from 'status' 
 
 ix : index corresponding to the end point 
      'y' changes to other value from 'status' 
      
 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_end(y,status,t_stay)
0002 % Find time points that signal differ from 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_end(y,status)
0006 %     ix = vb_bit_ptn_end(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 %          Then, 'y' changes to other value from 'status'
0013 %
0014 % ix : index corresponding to the end point
0015 %      'y' changes to other value from 'status'
0016 %
0017 % 2009-6-11 Masa-aki Sato
0018 % 2012-1-8  Masa-aki Sato Bug fix
0019 %
0020 % Copyright (C) 2011, ATR All Rights Reserved.
0021 % License : New BSD License(see VBMEG_LICENSE.txt)
0022 
0023 if nargin < 3, t_stay = 10; end;
0024 
0025 T = length(y);
0026 
0027 % take bitwise AND to ignore irrelevant bit
0028 y = bitand(y,status);
0029 
0030 flg = ones(1,T-t_stay);
0031 tt  = 1:T-t_stay;
0032 
0033 % 'y' is not 'status' value afterward
0034 flg = flg .* (y(tt + t_stay) ~= status);
0035 
0036 % 'y' should be stay at the value 'status' for more than t_stay
0037 for t=0:t_stay-1
0038     flg = flg .* (y(tt + t) == status);
0039 end
0040 
0041 ix = find(flg == 1);
0042 ix = ix + t_stay - 1;
0043 
0044 return

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