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

vb_get_status_integer

PURPOSE ^

get status bit pattern from tnteger status signal

SYNOPSIS ^

function [result] = vb_get_status_integer(status,bit_ptn,bit_max)

DESCRIPTION ^

 get status bit pattern from tnteger status signal
 [usage]
   [result] = vb_get_status_integer(status,bit_ptn,bit_max)
 [input]
   status  : integer status signal [ 1 x n_sample ]
   bit_ptn : bit number list to get specified bit data from status signal
           = [1:8] : get 1 to 8 bit from status
   bit_max : bit length of original status signal before converted to integer
           = [24] for Biosemi 
 [output]
        result : integer value converted from status [1 x n_sample]
   2009-6-25 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 [result] = vb_get_status_integer(status,bit_ptn,bit_max)
0002 % get status bit pattern from tnteger status signal
0003 % [usage]
0004 %   [result] = vb_get_status_integer(status,bit_ptn,bit_max)
0005 % [input]
0006 %   status  : integer status signal [ 1 x n_sample ]
0007 %   bit_ptn : bit number list to get specified bit data from status signal
0008 %           = [1:8] : get 1 to 8 bit from status
0009 %   bit_max : bit length of original status signal before converted to integer
0010 %           = [24] for Biosemi
0011 % [output]
0012 %        result : integer value converted from status [1 x n_sample]
0013 %   2009-6-25 Masa-aki Sato
0014 %
0015 % Copyright (C) 2011, ATR All Rights Reserved.
0016 % License : New BSD License(see VBMEG_LICENSE.txt)
0017 
0018 %
0019 result=[];
0020 [M, T] = size(status);
0021 if T==1 && M > 1, status = status'; T = M; M = 1; end;
0022 
0023 if M > 1, error('status should be 1 x T'); end;
0024 if nargin < 2, bit_ptn = 1:8; end;
0025 if nargin < 3, bit_max = 24; end;
0026 
0027 status = double(status);
0028 
0029 % convert negative integer to positive integer
0030 ix = find( status < 0 );
0031 status(ix) = status(ix) + 2^bit_max;
0032 
0033 bit_len = length(bit_ptn);
0034 
0035 result = zeros(1, T);
0036 
0037 for i_bit = 1:bit_len
0038     % get specified bit value
0039     i_val = 2^bit_ptn(i_bit);
0040      result = bitand(status, i_val) + result;
0041 end
0042 
0043 %result = zeros(bit_len, T);
0044 %
0045 %for i_bit = 1:bit_len
0046 %    i_val = 2^bit_ptn(i_bit);
0047 %     result(i_bit,:) = bitand(status, i_val)/i_val;
0048 %end
0049 
0050 % BITAND ビット単位の論理積
0051 %  C = BITAND(A,B) は、2つの引数 A と B のビット単位の論理積を出力します。
0052 %  A と B は、符号なしの整数でなければなりません。
0053  
0054 % BITGET ビットの取り出し
0055 %  C = BITGET(A,BIT)
0056 %  A の中の位置 BIT にあるビット値を出力します。
0057 %  A は、符号なし整数で、
0058 %  BIT は 1 と A の符号なし整数のクラスのビット数
0059 %  (UINT32では32)の間の値でなければなりません。
0060 %
0061 return;
0062 %
0063 % --- END OF MAIN PROCEDURE --- %

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