<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Advanced MATLAB: Timer objects</title>
	<link>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/</link>
	<description>Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.</description>
	<pubDate>Sun, 22 Nov 2009 23:15:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: dhull</title>
		<link>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1545</link>
		<dc:creator>dhull</dc:creator>
		<pubDate>Thu, 27 Aug 2009 15:08:11 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1545</guid>
		<description>@ryan,

If the calculation that is taking too long is in a for loop, or anything else where you can force a check from time to time, I would have the timer SETAPPDATA in the root (handle 0) after a certain amount of time.  I would then have the calculation check for that data from time to time with GETAPPDATA.

This appdata shoudl be available from any workspace.

-Let me know,
Doug</description>
		<content:encoded><![CDATA[<p>@ryan,</p>
<p>If the calculation that is taking too long is in a for loop, or anything else where you can force a check from time to time, I would have the timer SETAPPDATA in the root (handle 0) after a certain amount of time.  I would then have the calculation check for that data from time to time with GETAPPDATA.</p>
<p>This appdata shoudl be available from any workspace.</p>
<p>-Let me know,<br />
Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan W</title>
		<link>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1543</link>
		<dc:creator>Ryan W</dc:creator>
		<pubDate>Wed, 26 Aug 2009 18:21:18 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1543</guid>
		<description>Nice blog, Doug.

I'm trying to use a timer to exit a function that's taking too long to execute, similar to what Bob (#1 above) says he does. However, since the timer executes in the base workspace, I haven't been able to figure out how it can tell the function to return (preferably with an error).
As a simple example, when I run this function the message displays, but the workspace remains paused:

&lt;pre&gt;
[] = function test()

t = timer('TimerFcn','disp(''Taking too long''); return','StartDelay',5);

start(t)

pause
&lt;/pre&gt;

Is there a way to set up the timer so that function test will terminate?

Thanks,
Ryan</description>
		<content:encoded><![CDATA[<p>Nice blog, Doug.</p>
<p>I&#8217;m trying to use a timer to exit a function that&#8217;s taking too long to execute, similar to what Bob (#1 above) says he does. However, since the timer executes in the base workspace, I haven&#8217;t been able to figure out how it can tell the function to return (preferably with an error).<br />
As a simple example, when I run this function the message displays, but the workspace remains paused:</p>
<pre>
[] = function test()

t = timer('TimerFcn','disp(''Taking too long''); return','StartDelay',5);

start(t)

pause
</pre>
<p>Is there a way to set up the timer so that function test will terminate?</p>
<p>Thanks,<br />
Ryan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dhull</title>
		<link>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1535</link>
		<dc:creator>dhull</dc:creator>
		<pubDate>Fri, 14 Aug 2009 15:43:29 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1535</guid>
		<description>If you want access to the handles structure from outside the GUI, you might want to store a copy of the data you need in the root object (handle = 0) with GETAPPDATA and SETAPPDATA.  It really depends on the specifics of what you are trying to do.  Without more information, I can not really make a good suggestion.

Doug</description>
		<content:encoded><![CDATA[<p>If you want access to the handles structure from outside the GUI, you might want to store a copy of the data you need in the root object (handle = 0) with GETAPPDATA and SETAPPDATA.  It really depends on the specifics of what you are trying to do.  Without more information, I can not really make a good suggestion.</p>
<p>Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tejaprtap</title>
		<link>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1534</link>
		<dc:creator>Tejaprtap</dc:creator>
		<pubDate>Fri, 14 Aug 2009 08:41:07 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1534</guid>
		<description>dear doug,

i need the timer function, TimerFcn to work on the handles structure when i'm working in a gui, i've tried a ton of things, nothing's worked, could you help me out?

i think its a workspace issue, but i dont know how to fix it.</description>
		<content:encoded><![CDATA[<p>dear doug,</p>
<p>i need the timer function, TimerFcn to work on the handles structure when i&#8217;m working in a gui, i&#8217;ve tried a ton of things, nothing&#8217;s worked, could you help me out?</p>
<p>i think its a workspace issue, but i dont know how to fix it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dhull</title>
		<link>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1509</link>
		<dc:creator>dhull</dc:creator>
		<pubDate>Mon, 20 Jul 2009 15:32:21 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1509</guid>
		<description>Bill,

My first guess is that you are going to want to write an actual subfunction in the code (not defining 'handles.elapsedTime = toc;')  When you make that subfunction, be sure to actually pas in and take handles out of the function.

I think you are running into scoping issues.

-Doug</description>
		<content:encoded><![CDATA[<p>Bill,</p>
<p>My first guess is that you are going to want to write an actual subfunction in the code (not defining &#8216;handles.elapsedTime = toc;&#8217;)  When you make that subfunction, be sure to actually pas in and take handles out of the function.</p>
<p>I think you are running into scoping issues.</p>
<p>-Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill</title>
		<link>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1508</link>
		<dc:creator>Bill</dc:creator>
		<pubDate>Fri, 17 Jul 2009 20:41:44 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1508</guid>
		<description>Hey Doug!

You blog is a lifesaver. My question for you is, I'm trying to make a GUI with some really accurate timing for events, i.e. moving boxes at certain times, having a running clock, changing colors at certain times, etc. What I want to do is use tic;toc; to give me a running time from the start and save the toc's return value to the GUI's handle structure. However, when I seem to do that, it seems to destroy the Handles structue, as I get the "Reference to non-existent field" error for variables that existed just a second ago. Any ideas, or is TIMER not the way to roll?

&lt;pre&gt;
function figure1_KeyPressFcn(hObject, eventdata, handles)
handles.Key = get(gcf, 'CurrentKey')

switch(handles.Key)
case 'f12'

tic;
accurateTimer = timer;
set(accurateTimer, 'Period', .1)
set(accurateTimer, 'TimerFcn', 'handles.elapsedTime = toc;')
start(accurateTimer)

handles.workingTime = floor(handles.elapsedTime) %%Where I get my "Reference to Nonexistent Field Error"

&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hey Doug!</p>
<p>You blog is a lifesaver. My question for you is, I&#8217;m trying to make a GUI with some really accurate timing for events, i.e. moving boxes at certain times, having a running clock, changing colors at certain times, etc. What I want to do is use tic;toc; to give me a running time from the start and save the toc&#8217;s return value to the GUI&#8217;s handle structure. However, when I seem to do that, it seems to destroy the Handles structue, as I get the &#8220;Reference to non-existent field&#8221; error for variables that existed just a second ago. Any ideas, or is TIMER not the way to roll?</p>
<pre>
function figure1_KeyPressFcn(hObject, eventdata, handles)
handles.Key = get(gcf, 'CurrentKey')

switch(handles.Key)
case 'f12'

tic;
accurateTimer = timer;
set(accurateTimer, 'Period', .1)
set(accurateTimer, 'TimerFcn', 'handles.elapsedTime = toc;')
start(accurateTimer)

handles.workingTime = floor(handles.elapsedTime) %%Where I get my "Reference to Nonexistent Field Error"
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Ollos</title>
		<link>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1237</link>
		<dc:creator>Ryan Ollos</dc:creator>
		<pubDate>Fri, 21 Nov 2008 07:59:43 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1237</guid>
		<description>Hi Doug,

That basically answers my question, however I would like to better understand how timer callbacks and user-generated event callbacks (i.e. handle graphics object callbacks) interact.

If MATLAB is single threaded the events must be processed serially, but can a timer callback interrupt a handle graphics callback with interruptible property = 'on' (when it reaches one of the function calls that allow it to be interrupted such as drawnow, pause, etc ...)?  

Since the timer callback does not have an interruptible property, can it be interrupted by any other callback in the event queue?

- Ryan</description>
		<content:encoded><![CDATA[<p>Hi Doug,</p>
<p>That basically answers my question, however I would like to better understand how timer callbacks and user-generated event callbacks (i.e. handle graphics object callbacks) interact.</p>
<p>If MATLAB is single threaded the events must be processed serially, but can a timer callback interrupt a handle graphics callback with interruptible property = &#8216;on&#8217; (when it reaches one of the function calls that allow it to be interrupted such as drawnow, pause, etc &#8230;)?  </p>
<p>Since the timer callback does not have an interruptible property, can it be interrupted by any other callback in the event queue?</p>
<p>- Ryan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dhull</title>
		<link>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1230</link>
		<dc:creator>dhull</dc:creator>
		<pubDate>Wed, 19 Nov 2008 18:43:57 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1230</guid>
		<description>@Med,

There were no timer objects in that release of MATLAB.  That is why we recommend upgrading to newer versions of MATLAB.

-Doug</description>
		<content:encoded><![CDATA[<p>@Med,</p>
<p>There were no timer objects in that release of MATLAB.  That is why we recommend upgrading to newer versions of MATLAB.</p>
<p>-Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dhull</title>
		<link>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1229</link>
		<dc:creator>dhull</dc:creator>
		<pubDate>Wed, 19 Nov 2008 16:03:59 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1229</guid>
		<description>Ryan,

MATLAB is single threaded.

If you want to update graphics, at any time you can call DRAWNOW.  This will flush the graphics queue.

Does this answer the heart of your question?

-Doug</description>
		<content:encoded><![CDATA[<p>Ryan,</p>
<p>MATLAB is single threaded.</p>
<p>If you want to update graphics, at any time you can call DRAWNOW.  This will flush the graphics queue.</p>
<p>Does this answer the heart of your question?</p>
<p>-Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Ollos</title>
		<link>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1228</link>
		<dc:creator>Ryan Ollos</dc:creator>
		<pubDate>Wed, 19 Nov 2008 03:12:16 +0000</pubDate>
		<guid>http://blogs.mathworks.com/videos/2008/05/05/advanced-matlab-timer-objects/#comment-1228</guid>
		<description>Hi Doug,

Do Timer Callbacks and Handle Graphics Object Callbacks execute in the same Event Queue (i.e. same thread)?  And if so, what is the Interruptible property behavior of the Timer Callback (since that is not one of its visible properties)?

I'd like to understand, if I have a Timer Callback that takes a long time to complete, can my Handle Graphics objects be updated during that time period?  I've been trying to figure this out through an test case, but I'm running into some trouble.

- Ryan</description>
		<content:encoded><![CDATA[<p>Hi Doug,</p>
<p>Do Timer Callbacks and Handle Graphics Object Callbacks execute in the same Event Queue (i.e. same thread)?  And if so, what is the Interruptible property behavior of the Timer Callback (since that is not one of its visible properties)?</p>
<p>I&#8217;d like to understand, if I have a Timer Callback that takes a long time to complete, can my Handle Graphics objects be updated during that time period?  I&#8217;ve been trying to figure this out through an test case, but I&#8217;m running into some trouble.</p>
<p>- Ryan</p>
]]></content:encoded>
	</item>
</channel>
</rss>
