view general/funutils/scanrcols.m @ 6:0ce3c2070089

Removed duplicate code and fixed doc in timed_action.
author samer
date Mon, 14 Jan 2013 14:33:37 +0000
parents e44f49929e56
children
line wrap: on
line source
% scanrcols - scan array columns from the right
%
% scanrcols :; 
%    ([[M]], [[N]] -> [[M]])   ~'scannning function',
%    [[M]]                     ~'initial value',
%    [[N,L]]                   ~'data to scan, sequence of length L'
% -> [[M,L]].

function Y=scanrcols(f,y,X,varargin)
	Y=zeros(size(y,1),size(X,2));

	if nargin>3
		opts=prefs('draw',0,varargin{:});
		for i=size(X,2):-1:1
			y1=f(y,X(:,i));
			Y(:,i)=y1;
			if opts.draw, opts.plotfn(i,y,X(:,i),y1);  end
			optpause(opts);
			y=y1;
		end
	else
		for i=size(X,2):-1:1, y=f(y,X(:,i)); Y(:,i)=y; end
	end