set values for cylinder [J, Y] = set_cylinder_val(Y,U,t,NP,dN) Y : ring buffer for temporal histry U : current state value t : current time index dN: number of cylinder points 2014-11-10 Masa-aki Sato Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [J, Y, tp] = set_cylinder_val(Y,U,t,dN) 0002 % set values for cylinder 0003 % [J, Y] = set_cylinder_val(Y,U,t,NP,dN) 0004 % Y : ring buffer for temporal histry 0005 % U : current state value 0006 % t : current time index 0007 % dN: number of cylinder points 0008 % 0009 % 2014-11-10 Masa-aki Sato 0010 % 0011 % Copyright (C) 2011, ATR All Rights Reserved. 0012 % License : New BSD License(see VBMEG_LICENSE.txt) 0013 0014 NP = length(Y); 0015 0016 if isempty(U) 0017 y = Y; 0018 tc = mod(t-1 , NP) + 1; 0019 tp = mod(tc - (1:NP), NP) + 1; 0020 y = y(tp); 0021 else 0022 % time index for ring buffer 0023 tc = mod(t-1 , NP) + 1; 0024 0025 % set current state value 0026 Y(tc) = U; 0027 y = Y; 0028 0029 % time index to show temporal histry 0030 tp = mod(tc - (1:NP), NP) + 1; 0031 y = y(tp); 0032 end 0033 0034 % replicate values for cylinder 0035 J = repmat(y(:), [1 dN]); 0036 J = J'; J = J(:);