samer@0: % ufold - Fold data into processing unit samer@0: % samer@0: % ufold :: samer@0: % unit({[[N,1]]}, _, S) ~'live processing unit', samer@0: % [[N,T]] ~'data to pass through', samer@0: % S ~'initial state of unit', samer@0: % options { samer@0: % draw :: boolean/false ~'whether or not to call drawnow after each iteration'; samer@0: % quiet :: boolean/false ~'whether or not to suppress progress messages' samer@0: % } samer@0: % -> S ~'final state'. samer@0: % samer@0: % This function accepts the live processing unit associated samer@0: % with an arrow (as created by with_arrow). The arrow must samer@0: % accept one column vector as input. Its output is ignored. samer@0: % The state of the unit is first set, then data is passed samer@0: % through one column at a time, and the final state is returned. samer@0: samer@0: function A2=ufold(unit,X,A1,varargin) samer@0: if ~isempty(A1), unit.set_state(A1); end samer@0: uiter(unit,size(X,2),@foldx,[],'label','ufold',varargin{:}); samer@0: A2=unit.get_state(); samer@0: samer@0: function s=foldx(i,s), unit.process(X(:,i)); end samer@0: end