view general/funutils/scancols.m @ 4:e44f49929e56

Adding reorganised general toolbox, now in several subdirectories.
author samer
date Sat, 12 Jan 2013 19:21:22 +0000
parents
children
line wrap: on
line source
% scancols :; 
%    ([[M]], [[N]] -> [[M]])   ~'scannning function',
%    [[M]]                     ~'initial value',
%    [[N,L]]                   ~'data to scan, sequence of length L'
% -> [[M,L]].

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

	if nargin>3
		opts=prefs('draw',0,varargin{:});
		for i=1:size(X,2)
			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=1:size(X,2), y=f(y,X(:,i)); Y(:,i)=y; end
	end