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

vb_get_status_mask

PURPOSE ^

get status value by masking irrelevant bit

SYNOPSIS ^

function y = vb_get_status_mask(x, mask_bit, status_offset)

DESCRIPTION ^

 get status value by masking irrelevant bit
  y = vb_get_status_mask(x)
  y = vb_get_status_mask(x, mask_bit)
  y = vb_get_status_mask(x, mask_bit, status_offset)
 --- Input
  x : status signal (1 x T or T x 1)
  status_offset : shift value for status
    x = x - status_offset
  mask_bit : binary bit mask pattern [STRING]
   Ex.  '1100' 
 Matlab binary expression
 Left-> higher bit Right-> lower bit
  12 =   1100
  20 =  10100
  28 =  11100
  36 = 100100
 
 2009-6-10 Masa-aki Sato

 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    y = vb_get_status_mask(x, mask_bit, status_offset)
0002 % get status value by masking irrelevant bit
0003 %  y = vb_get_status_mask(x)
0004 %  y = vb_get_status_mask(x, mask_bit)
0005 %  y = vb_get_status_mask(x, mask_bit, status_offset)
0006 % --- Input
0007 %  x : status signal (1 x T or T x 1)
0008 %  status_offset : shift value for status
0009 %    x = x - status_offset
0010 %  mask_bit : binary bit mask pattern [STRING]
0011 %   Ex.  '1100'
0012 % Matlab binary expression
0013 % Left-> higher bit Right-> lower bit
0014 %  12 =   1100
0015 %  20 =  10100
0016 %  28 =  11100
0017 %  36 = 100100
0018 %
0019 % 2009-6-10 Masa-aki Sato
0020 %
0021 % Copyright (C) 2011, ATR All Rights Reserved.
0022 % License : New BSD License(see VBMEG_LICENSE.txt)
0023 
0024 % dec2bin(d) は、dの2進数表現を文字列として出力
0025 % bin2dec(binarystr)は、バイナリ文字列を等価な10進数として出力
0026 % C=bitand(A,B)は、2つの非負の整数引数AとBのビット単位の論理積
0027 
0028 % value for NIRS-EEG online BCI
0029 %
0030 %Trigger.Task1       = 12;    %  00110000  NIRS=1
0031 %Trigger.Task2       = 20;    %  00101000  NIRS=2
0032 %Trigger.Task3       = 28;    %  00111000  NIRS=3
0033 %Trigger.Task4       = 36;    %  00100100  NIRS=4
0034 
0035 
0036 % Offset
0037 if nargin < 3 || isempty(status_offset)
0038     status_offset = 0;
0039 end
0040 
0041 % Mask Bit
0042 if nargin < 2 || isempty(mask_bit)
0043     mask_bit = '';
0044 end
0045 
0046 y = x - status_offset;
0047 if ~isempty(mask_bit)
0048     mask_val = bin2dec(mask_bit);
0049     y = bitand(y, mask_val);
0050 end
0051 
0052 return
0053 
0054 %y = zeros(size(x));
0055 %
0056 %for n=1:length(x)
0057 %    y(n) = bitand(x(n),mask_val);
0058 %end

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