diff general/funutils/scanner_add_plotter.m @ 12:fbc0540a9208

Moved some high-order functions from funutils to arrutils, updated docs and cleaned up funutils.
author samer
date Mon, 14 Jan 2013 22:21:11 +0000
parents
children 8f4a21082c45
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/general/funutils/scanner_add_plotter.m	Mon Jan 14 22:21:11 2013 +0000
@@ -0,0 +1,16 @@
+% scanner_add_plotter - Add plotting capabilities to scan function
+%
+% scanner_add_plotter ::
+%    (S,X->S) ~'scanning function',
+%    options {
+%       draw    :: bool/false ~'enable drawing if true';
+%       pause   :: natural/0 ~'pause duration in ms';
+%       drawnow :: bool/true ~'whether or not to call drawnow afterwards'
+%    }
+% -> (S,X->X) ~'new scanning function'.
+
+function f1=scanner_add_plotter(f,opts)
+	opts=prefs('draw',0,varargin{:});
+	if ~opts.draw, f1=f; else ps=pauser(opts); f1=@g; end
+	function y1=g(y,x), y1={f(y,x),i}; opts.plotfn(x,y,y1); ps(); end
+end