<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Practical Example: Adding callbacks to a plot</title>
	<atom:link href="http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/</link>
	<description>&#60;a href=&#34;http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectId=1093599&#38;objectType=author&#34;&#62;Brett&#60;/a&#62; &#38; &#60;a href=&#34;http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectId=1094142&#38;objectType=author&#34;&#62;Jiro&#60;/a&#62; share favorite user-contributed submissions from the File Exchange.</description>
	<lastBuildDate>Fri, 10 Feb 2012 16:12:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Doug</title>
		<link>http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-10102</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Thu, 20 Mar 2008 15:45:46 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-10102</guid>
		<description>Yonathan,

Two things are happening here:  There is a nested function, and a function handle.  The function handle (the @ symbol creates it) snapshots the workspace of the main function upon creation.  This is how the variable stay &quot;alive&quot;.  The scoping into the nested function is as discussed in my video.

Thanks for a great question!
Doug</description>
		<content:encoded><![CDATA[<p>Yonathan,</p>
<p>Two things are happening here:  There is a nested function, and a function handle.  The function handle (the @ symbol creates it) snapshots the workspace of the main function upon creation.  This is how the variable stay &#8220;alive&#8221;.  The scoping into the nested function is as discussed in my video.</p>
<p>Thanks for a great question!<br />
Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yonathan Nativ</title>
		<link>http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-10095</link>
		<dc:creator>Yonathan Nativ</dc:creator>
		<pubDate>Thu, 20 Mar 2008 09:12:04 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-10095</guid>
		<description>Hi Doug,

In your demo the main function has ended. I thought when the function ends all its variables die.

The nested function is called through a callback, why does the callback revive the main function?

Thanks again,

Yonathan</description>
		<content:encoded><![CDATA[<p>Hi Doug,</p>
<p>In your demo the main function has ended. I thought when the function ends all its variables die.</p>
<p>The nested function is called through a callback, why does the callback revive the main function?</p>
<p>Thanks again,</p>
<p>Yonathan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-10082</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Wed, 19 Mar 2008 18:31:47 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-10082</guid>
		<description>Yonathan,

hdd and hdp were in scope in the highlightPair function because it is a nested function and has access to the variables of the outer function.  See this video for more details:

http://blogs.mathworks.com/pick/2008/02/01/matlab-basics-nested-functions/

Thanks,
Doug</description>
		<content:encoded><![CDATA[<p>Yonathan,</p>
<p>hdd and hdp were in scope in the highlightPair function because it is a nested function and has access to the variables of the outer function.  See this video for more details:</p>
<p><a href="http://blogs.mathworks.com/pick/2008/02/01/matlab-basics-nested-functions/" rel="nofollow">http://blogs.mathworks.com/pick/2008/02/01/matlab-basics-nested-functions/</a></p>
<p>Thanks,<br />
Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yonathan Nativ</title>
		<link>http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-10081</link>
		<dc:creator>Yonathan Nativ</dc:creator>
		<pubDate>Wed, 19 Mar 2008 18:15:39 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-10081</guid>
		<description>Hi Doug,

Nice video, One question though:

How does the &quot;highlightPair&quot; function knows the variables hdd &amp; hdp?


Thanks,

Yonathan</description>
		<content:encoded><![CDATA[<p>Hi Doug,</p>
<p>Nice video, One question though:</p>
<p>How does the &#8220;highlightPair&#8221; function knows the variables hdd &amp; hdp?</p>
<p>Thanks,</p>
<p>Yonathan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-9208</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Mon, 04 Feb 2008 18:35:32 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-9208</guid>
		<description>plot(rand(1,10))
k = waitforbuttonpress;
point1 = get(gca,&#039;CurrentPoint&#039;)

This will get you the current point that you click on.  An example like this was done here:

http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/</description>
		<content:encoded><![CDATA[<p>plot(rand(1,10))<br />
k = waitforbuttonpress;<br />
point1 = get(gca,&#8217;CurrentPoint&#8217;)</p>
<p>This will get you the current point that you click on.  An example like this was done here:</p>
<p><a href="http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/" rel="nofollow">http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Will</title>
		<link>http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-9015</link>
		<dc:creator>Will</dc:creator>
		<pubDate>Thu, 31 Jan 2008 16:56:05 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-9015</guid>
		<description>Great Post, I always tried to do this but could never get it to work properly.

Is there a similar way to do this with a &#039;line&#039; instead of a &#039;point&#039;.  If I were to make a line with a ButtdownFnc is there a way I could get the (x,y) coordinates of the clicking?  I see that I could potentially plot each of the points individually as you did above, but it seems like there might be a more elegant way to do this.

Thanks</description>
		<content:encoded><![CDATA[<p>Great Post, I always tried to do this but could never get it to work properly.</p>
<p>Is there a similar way to do this with a &#8216;line&#8217; instead of a &#8216;point&#8217;.  If I were to make a line with a ButtdownFnc is there a way I could get the (x,y) coordinates of the clicking?  I see that I could potentially plot each of the points individually as you did above, but it seems like there might be a more elegant way to do this.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-8969</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Tue, 29 Jan 2008 16:20:24 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-8969</guid>
		<description>I am normally an advocate of SETAPPDATA, GETAPPDATA.  However, for this specific case I was storing a very small amount of data and this was a very easy way of doing this.

Thanks for adding to this with your technique.

Doug</description>
		<content:encoded><![CDATA[<p>I am normally an advocate of SETAPPDATA, GETAPPDATA.  However, for this specific case I was storing a very small amount of data and this was a very easy way of doing this.</p>
<p>Thanks for adding to this with your technique.</p>
<p>Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Markus</title>
		<link>http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-8951</link>
		<dc:creator>Markus</dc:creator>
		<pubDate>Mon, 28 Jan 2008 21:40:21 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-8951</guid>
		<description>I am glad you are using a technique I also use for GUIs, namely saving data in the &#039;userdata&#039; field of objects and/or the main figure. In my opinion this is much clearer then using handles to nested functions.

You can even store more information in the userdata field using a struct. It just needs some discipline and little more lines of code for adding or updating data:

str = get(gcf, &#039;userdata&#039;);
str.myfield = something;
set(gcf, &#039;userdata&#039;, str);

Markus</description>
		<content:encoded><![CDATA[<p>I am glad you are using a technique I also use for GUIs, namely saving data in the &#8216;userdata&#8217; field of objects and/or the main figure. In my opinion this is much clearer then using handles to nested functions.</p>
<p>You can even store more information in the userdata field using a struct. It just needs some discipline and little more lines of code for adding or updating data:</p>
<p>str = get(gcf, &#8216;userdata&#8217;);<br />
str.myfield = something;<br />
set(gcf, &#8216;userdata&#8217;, str);</p>
<p>Markus</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-8944</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Mon, 28 Jan 2008 15:53:32 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-8944</guid>
		<description>Dan,

Sorry no, that was just video editing.  In an effort to keep the video shorter this time, I was cutting out parts where I was silently typing.  I highlighted them blue in an effort to give an idea that I was &#039;faking it&#039;.

Sorry for the confusion!

Doug</description>
		<content:encoded><![CDATA[<p>Dan,</p>
<p>Sorry no, that was just video editing.  In an effort to keep the video shorter this time, I was cutting out parts where I was silently typing.  I highlighted them blue in an effort to give an idea that I was &#8216;faking it&#8217;.</p>
<p>Sorry for the confusion!</p>
<p>Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Mac</title>
		<link>http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-8943</link>
		<dc:creator>Dan Mac</dc:creator>
		<pubDate>Mon, 28 Jan 2008 15:42:58 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2008/01/28/practical-example-adding-callbacks-to-a-plot/#comment-8943</guid>
		<description>I&#039;ve got a question about the editor.  About 10 1/2 minutes into the video, you edited two lines at the same time (changing &quot;set(hdd(pairNum)&quot; to &quot;set(hdd(current)&quot;.  I was curious if you really did change both lines at the same time, and if so, how did you do it.

Thanks</description>
		<content:encoded><![CDATA[<p>I&#8217;ve got a question about the editor.  About 10 1/2 minutes into the video, you edited two lines at the same time (changing &#8220;set(hdd(pairNum)&#8221; to &#8220;set(hdd(current)&#8221;.  I was curious if you really did change both lines at the same time, and if so, how did you do it.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>

