Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!w37g2000prg.googlegroups.com!not-for-mail
From: swgillan <swgillan@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Running a function in the background
Date: Wed, 30 Sep 2009 19:52:47 -0700 (PDT)
Organization: http://groups.google.com
Lines: 67
Message-ID: <43fc2ee2-059a-4a4f-8455-1adf0388a02d@w37g2000prg.googlegroups.com>
References: <f48e68c5-54f4-41b8-9843-0d8c995366b0@i4g2000prm.googlegroups.com> 
	<h9qgfl$a89$1@fred.mathworks.com> <105ea682-707d-4779-b613-cd1c8bb7cfe0@e4g2000prn.googlegroups.com> 
	<h9vog1$4sb$1@fred.mathworks.com>
NNTP-Posting-Host: 96.50.69.170
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1254365567 23535 127.0.0.1 (1 Oct 2009 02:52:47 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 1 Oct 2009 02:52:47 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: w37g2000prg.googlegroups.com; posting-host=96.50.69.170; 
	posting-account=oG0_2QoAAADs2vBCPqAYFyNKpnhzubZa
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.3) 
	Gecko/20090824 Firefox/3.5.3,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:574104


Thanks for sharing that, I have never used a lot of the gcf stuff, so
I will look over that code and take what I can from it. I was also
passed on the watch_malloc code from the presenter, so I should be
able to figure out how things were done!

Thanks for all the help.

Now all I need is to find out why 3d plotting is messed up in Ubuntu
9.04 (I think it is an intel graphics driver problem).

Regards,

Steven Gillan
>
> If I were implementing something like that, I'd use a Timer object to
> periodically run a function that updates the figure.  As a small example:
>
> function comet2(delayS, x, y)
> % COMET2 Display points in a line with a delay between each point display
> %
> % COMET2(delayS, x, y) displays each of the points represented by elements
> % in the x and y vectors with a delay of delayS seconds between each point.
>
> if ~isequal(numel(x), numel(y))
>     error('comet2:invalidCoords', 'The x and y inputs must have the same
> number of elements.');
> end
>
> if ~isreal(delayS) || delayS <= 0 || ~isscalar(delayS) || ~isfinite(delayS)
>     error('comet2:invalidDelayS', 'The delay must be a real finite positive
> scalar.');
> end
>
> h = line(NaN, NaN);
> axis([min(x) max(x) min(y) max(y)])
> set(h, 'UserData', 1);
>
> t = timer('TasksToExecute', numel(x), ...
>     'ExecutionMode', 'fixedRate', ...
>     'StartDelay', 0, ...
>     'Period', delayS);
> set(t, 'TimerFcn', @(varargin) updatePlot(h, x, y, t), ...
>     'StopFcn', @(varargin) delete(t));
> start(t);
>
> function updatePlot(h, x, y, t)
> try
>     nextPoint = get(h, 'UserData');
>     set(h, 'XData', x(1:nextPoint), 'YData', y(1:nextPoint), 'UserData',
> nextPoint+1);
> catch %#ok<CTCH>
>     stop(t);
> end
>
> --
> Steve Lord
> sl...@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ:http://matlabwiki.mathworks.com/MATLAB_FAQ