<?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: Continuous slider callback</title> <atom:link href="http://undocumentedmatlab.com/blog/continuous-slider-callback/feed/" rel="self" type="application/rss+xml" /><link>http://undocumentedmatlab.com/blog/continuous-slider-callback/</link> <description>Charting Matlab's unsupported hidden underbelly</description> <lastBuildDate>Fri, 18 May 2012 13:56:51 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.1</generator> <item><title>By: Alfonso</title><link>http://undocumentedmatlab.com/blog/continuous-slider-callback/#comment-78457</link> <dc:creator>Alfonso</dc:creator> <pubDate>Wed, 21 Mar 2012 07:09:36 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1052#comment-78457</guid> <description>This is awesome!
Thank you!</description> <content:encoded><![CDATA[<p>This is awesome!<br
/> Thank you!</p> ]]></content:encoded> </item> <item><title>By: John</title><link>http://undocumentedmatlab.com/blog/continuous-slider-callback/#comment-74760</link> <dc:creator>John</dc:creator> <pubDate>Sat, 18 Feb 2012 15:00:33 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1052#comment-74760</guid> <description>Hi guys,i just wanted to add my solution to the continuous slider problem, which seems to be the simpliest/easiest way to understand (imho):&lt;i&gt; 1. Create the control: &lt;/i&gt;
&lt;pre lang=&quot;matlab&quot;&gt;
myslider = uicontrol(topWindowHandle, ...
&#039;Style&#039;, &#039;slider&#039;, ...
&#039;Min&#039;, 0, &#039;Max&#039;, 100, ...
&#039;Value&#039;, 25, ...
&#039;SliderStep&#039;, [0.05 0.2], ...
&#039;Position&#039;, [60 100 350 18]);
&lt;/pre&gt;
&lt;i&gt;2. Add a listener to the Value-property:&lt;/i&gt;
&lt;pre lang=&quot;matlab&quot;&gt;
addlistener(handle(myslider), &#039;Value&#039;, &#039;PostSet&#039;, @slider_callback);
&lt;/pre&gt;&lt;i&gt;3. Implement the slider-callback-function:&lt;/i&gt;
&lt;pre lang=&quot;matlab&quot;&gt;
function slider_callback(hObject, eventdata)
obj = get(eventdata, &#039;AffectedObject&#039;);
val = get(obj, &#039;Value&#039;);
display(val);
end
&lt;/pre&gt;
Now, val contains the actual slider value, because the AffectedObject-property holds the desired slider control, from which we can obtain our slider-value.GreetingsJohn</description> <content:encoded><![CDATA[<p>Hi guys,</p><p>i just wanted to add my solution to the continuous slider problem, which seems to be the simpliest/easiest way to understand (imho):</p><p><i> 1. Create the control: </i></p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">    myslider = <span style="color: #0000FF;">uicontrol</span><span style="color: #080;">&#40;</span>topWindowHandle, <span style="color: #F0F;">...</span>
        <span style="color:#A020F0;">'Style'</span>, <span style="color:#A020F0;">'slider'</span>, <span style="color: #F0F;">...</span>
        <span style="color:#A020F0;">'Min'</span>, <span style="color: #33f;">0</span>, <span style="color:#A020F0;">'Max'</span>, <span style="color: #33f;">100</span>, <span style="color: #F0F;">...</span>
        <span style="color:#A020F0;">'Value'</span>, <span style="color: #33f;">25</span>, <span style="color: #F0F;">...</span>
        <span style="color:#A020F0;">'SliderStep'</span>, <span style="color: #080;">&#91;</span><span style="color: #33f;">0.05</span> <span style="color: #33f;">0.2</span><span style="color: #080;">&#93;</span>, <span style="color: #F0F;">...</span>
        <span style="color:#A020F0;">'Position'</span>, <span style="color: #080;">&#91;</span><span style="color: #33f;">60</span> <span style="color: #33f;">100</span> <span style="color: #33f;">350</span> <span style="color: #33f;">18</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;</pre></div></div><p><i>2. Add a listener to the Value-property:</i></p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">addlistener<span style="color: #080;">&#40;</span>handle<span style="color: #080;">&#40;</span>myslider<span style="color: #080;">&#41;</span>, <span style="color:#A020F0;">'Value'</span>, <span style="color:#A020F0;">'PostSet'</span>, @slider_callback<span style="color: #080;">&#41;</span>;</pre></div></div><p><i>3. Implement the slider-callback-function:</i></p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">    <span style="color: #0000FF;">function</span> slider_callback<span style="color: #080;">&#40;</span>hObject, eventdata<span style="color: #080;">&#41;</span>
        obj = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>eventdata, <span style="color:#A020F0;">'AffectedObject'</span><span style="color: #080;">&#41;</span>;
        val = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>obj, <span style="color:#A020F0;">'Value'</span><span style="color: #080;">&#41;</span>;
        display<span style="color: #080;">&#40;</span>val<span style="color: #080;">&#41;</span>;
    <span style="color: #0000FF;">end</span></pre></div></div><p>Now, val contains the actual slider value, because the AffectedObject-property holds the desired slider control, from which we can obtain our slider-value.</p><p>Greetings</p><p>John</p> ]]></content:encoded> </item> <item><title>By: claus</title><link>http://undocumentedmatlab.com/blog/continuous-slider-callback/#comment-72274</link> <dc:creator>claus</dc:creator> <pubDate>Thu, 26 Jan 2012 16:34:47 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1052#comment-72274</guid> <description>Hi, thank you for your help!I turned my sliders into continuous just by adding two simple mods:first, add the following 2 lines to your xxxxxx_OpeningFcn:
&lt;pre lang=&quot;matlab&quot;&gt;
hListener=addlistener(handles.sliderN, &#039;ContinuousValueChange&#039;, @sliderN_Callback);
setappdata(handles.sliderN,&#039;myListener&#039;,hListener);
&lt;/pre&gt;then, add the following 3 lines to your sliderN_Callback:
&lt;pre lang=&quot;matlab&quot;&gt;
if ~(exist(&#039;handles&#039;,&#039;var&#039;))
handles=guidata(hObject);
end
&lt;/pre&gt;
It works like a charm!Thank you!</description> <content:encoded><![CDATA[<p>Hi, thank you for your help!</p><p>I turned my sliders into continuous just by adding two simple mods:</p><p>first, add the following 2 lines to your xxxxxx_OpeningFcn:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">hListener=addlistener<span style="color: #080;">&#40;</span>handles.<span style="">sliderN</span>, <span style="color:#A020F0;">'ContinuousValueChange'</span>, @sliderN_Callback<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">setappdata</span><span style="color: #080;">&#40;</span>handles.<span style="">sliderN</span>,<span style="color:#A020F0;">'myListener'</span>,hListener<span style="color: #080;">&#41;</span>;</pre></div></div><p>then, add the following 3 lines to your sliderN_Callback:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">if</span> ~<span style="color: #080;">&#40;</span><span style="color: #0000FF;">exist</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'handles'</span>,<span style="color:#A020F0;">'var'</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
     handles=guidata<span style="color: #080;">&#40;</span>hObject<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span></pre></div></div><p>It works like a charm!</p><p>Thank you!</p> ]]></content:encoded> </item> <item><title>By: Elise</title><link>http://undocumentedmatlab.com/blog/continuous-slider-callback/#comment-45061</link> <dc:creator>Elise</dc:creator> <pubDate>Sat, 28 May 2011 00:14:39 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1052#comment-45061</guid> <description>Thanks! Handle.listener worked great!</description> <content:encoded><![CDATA[<p>Thanks! Handle.listener worked great!</p> ]]></content:encoded> </item> <item><title>By: Matlab continuous slider callback &#171; Desperate Engineers Blog</title><link>http://undocumentedmatlab.com/blog/continuous-slider-callback/#comment-42575</link> <dc:creator>Matlab continuous slider callback &#171; Desperate Engineers Blog</dc:creator> <pubDate>Wed, 04 May 2011 08:53:55 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1052#comment-42575</guid> <description>[...] ([uicontrol(&#039;Style&#039;,&#039;slider&#039;, ...]) in a MATLAB GUI. Thanks to the posting of Yair Altman on this topic (on his awesome Undocumented Matlab Blog which you shoudl definitely check out), I had no problem [...]</description> <content:encoded><![CDATA[<p>[...] ([uicontrol(&#039;Style&#039;,&#039;slider&#039;, ...]) in a MATLAB GUI. Thanks to the posting of Yair Altman on this topic (on his awesome Undocumented Matlab Blog which you shoudl definitely check out), I had no problem [...]</p> ]]></content:encoded> </item> <item><title>By: Jonas</title><link>http://undocumentedmatlab.com/blog/continuous-slider-callback/#comment-40728</link> <dc:creator>Jonas</dc:creator> <pubDate>Thu, 21 Apr 2011 14:09:01 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1052#comment-40728</guid> <description>A short update form my side - as I now run on R2011a.I used to run a listener as proposed (R2010a/b) in the post the following way:
&lt;pre lang=&quot;matlab&quot;&gt;lh = addlistener(sliderhandle, &#039;ActionEvent&#039;,@MyCallback);
&lt;/pre&gt;The new Version of Matlab (R2011a) gives me a warning that I should not use this method anymore but rather use: a &quot;ContinuousValueChange&quot; Event.
So I end up with:
&lt;pre lang=&quot;matlab&quot;&gt;lh = addlistener(sliderhandle, &#039;ContinuousValueChange&#039;,@MyCallback);
&lt;/pre&gt;
which works pretty smooth. However, besides of that one-time-console-warning I have not found any documented information about this &quot;ContinuousValueChange&quot;-event or other hidden events...Best, Jonas</description> <content:encoded><![CDATA[<p>A short update form my side &#8211; as I now run on R2011a.</p><p>I used to run a listener as proposed (R2010a/b) in the post the following way:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">lh = addlistener<span style="color: #080;">&#40;</span>sliderhandle, <span style="color:#A020F0;">'ActionEvent'</span>,@MyCallback<span style="color: #080;">&#41;</span>;</pre></div></div><p>The new Version of Matlab (R2011a) gives me a warning that I should not use this method anymore but rather use: a &#8220;ContinuousValueChange&#8221; Event.<br
/> So I end up with:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">lh = addlistener<span style="color: #080;">&#40;</span>sliderhandle, <span style="color:#A020F0;">'ContinuousValueChange'</span>,@MyCallback<span style="color: #080;">&#41;</span>;</pre></div></div><p>which works pretty smooth. However, besides of that one-time-console-warning I have not found any documented information about this &#8220;ContinuousValueChange&#8221;-event or other hidden events&#8230;</p><p>Best, Jonas</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/continuous-slider-callback/#comment-39082</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Thu, 07 Apr 2011 10:36:05 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1052#comment-39082</guid> <description>@Jonas - these are essentially the same, except that &lt;i&gt;&lt;b&gt;addlistener&lt;/b&gt;&lt;/i&gt; adds the listener in a hidden property called &lt;b&gt;Listeners__&lt;/b&gt;, rather than in the similarly-hidden &lt;b&gt;ApplicationData&lt;/b&gt; property (which is what &lt;i&gt;&lt;b&gt;setappdata&lt;/b&gt;&lt;/i&gt; does).
&lt;pre lang=&#039;matlab&#039;&gt;
&gt;&gt; get(handles.mySlider, &#039;Listeners__&#039;)
ans =
handle.listener
&lt;/pre&gt;The actual place where the listener is stored does not matter. It is only important to store listeners together with the listened object, so that they both have exactly the same life-span. Both of these methods do that, by storing the listener in one of the object handle&#039;s properties.The source code for &lt;i&gt;&lt;b&gt;addlistener&lt;/b&gt;&lt;/i&gt; is not available in the latest Matlab releases (it&#039;s implemented as an internal function), but it is available and inspectable in Matlab releases up to 2008 (e.g., &lt;code&gt;C:\Program Files\Matlab\R2008a\toolbox\matlab\uitools\private\addlistener.m&lt;/code&gt;). This source code is not long (only ~30 code lines) and it&#039;s interesting, so I recommend looking at it.</description> <content:encoded><![CDATA[<p>@Jonas &#8211; these are essentially the same, except that <i><b>addlistener</b></i> adds the listener in a hidden property called <b>Listeners__</b>, rather than in the similarly-hidden <b>ApplicationData</b> property (which is what <i><b>setappdata</b></i> does).</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">&gt;&gt; <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>handles.<span style="">mySlider</span>, <span style="color:#A020F0;">'Listeners__'</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">ans</span> =
	<span style="color: #0000FF;">handle.<span style="">listener</span></span></pre></div></div><p>The actual place where the listener is stored does not matter. It is only important to store listeners together with the listened object, so that they both have exactly the same life-span. Both of these methods do that, by storing the listener in one of the object handle&#8217;s properties.</p><p>The source code for <i><b>addlistener</b></i> is not available in the latest Matlab releases (it&#8217;s implemented as an internal function), but it is available and inspectable in Matlab releases up to 2008 (e.g., <code>C:\Program Files\Matlab\R2008a\toolbox\matlab\uitools\private\addlistener.m</code>). This source code is not long (only ~30 code lines) and it&#8217;s interesting, so I recommend looking at it.</p> ]]></content:encoded> </item> <item><title>By: Jonas</title><link>http://undocumentedmatlab.com/blog/continuous-slider-callback/#comment-39078</link> <dc:creator>Jonas</dc:creator> <pubDate>Thu, 07 Apr 2011 09:56:38 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1052#comment-39078</guid> <description>Dear Yair
Your blog is just wonderful and helps me a lot these days in getting somewhere with my thesis. Thank your for your good work!Regarding the continuous slider callback, I wonder what the difference between
&lt;pre lang=&quot;matlab&quot;&gt;
hListener = handle.listener(handles.mySlider,&#039;ActionEvent&#039;,@mySliderMoved);
setappdata(handles.mySlider,&#039;mySliderListener&#039;,hListener);
&lt;/pre&gt; and &lt;pre lang=&quot;matlab&quot;&gt;
hListener = addlistener(handles.mySlider, &#039;ActionEvent&#039;, @mySliderMoved);
&lt;/pre&gt;
exactly is...?Best,
JonasPS. looking forward to your relevations of 2011a - coming tomorrow :)</description> <content:encoded><![CDATA[<p>Dear Yair<br
/> Your blog is just wonderful and helps me a lot these days in getting somewhere with my thesis. Thank your for your good work!</p><p>Regarding the continuous slider callback, I wonder what the difference between</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">hListener = <span style="color: #0000FF;">handle.<span style="">listener</span></span><span style="color: #080;">&#40;</span>handles.<span style="">mySlider</span>,<span style="color:#A020F0;">'ActionEvent'</span>,@mySliderMoved<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">setappdata</span><span style="color: #080;">&#40;</span>handles.<span style="">mySlider</span>,<span style="color:#A020F0;">'mySliderListener'</span>,hListener<span style="color: #080;">&#41;</span>;</pre></div></div><p> and</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">hListener = addlistener<span style="color: #080;">&#40;</span>handles.<span style="">mySlider</span>, <span style="color:#A020F0;">'ActionEvent'</span>, @mySliderMoved<span style="color: #080;">&#41;</span>;</pre></div></div><p>exactly is&#8230;?</p><p>Best,<br
/> Jonas</p><p>PS. looking forward to your relevations of 2011a &#8211; coming tomorrow <img
src='http://undocumentedmatlab.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Florin</title><link>http://undocumentedmatlab.com/blog/continuous-slider-callback/#comment-36081</link> <dc:creator>Florin</dc:creator> <pubDate>Tue, 08 Mar 2011 23:17:31 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1052#comment-36081</guid> <description>Yair,Thank you for your quick reply. That worked.
Hope you can maintain this site for a long time.
I wish you all the best.Regards,
Florin</description> <content:encoded><![CDATA[<p>Yair,</p><p>Thank you for your quick reply. That worked.<br
/> Hope you can maintain this site for a long time.<br
/> I wish you all the best.</p><p>Regards,<br
/> Florin</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/continuous-slider-callback/#comment-36006</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Tue, 08 Mar 2011 07:36:29 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=1052#comment-36006</guid> <description>@Florin - you probably have the same problem as Cemil and the solution is similar. In your slider callback, instead of using a simple &lt;b&gt;&lt;i&gt;imagesc&lt;/i&gt;&lt;/b&gt;, directly specify the parent axes:&lt;pre lang=&quot;matlab&quot;&gt;imagesc(&#039;Parent&#039;,handles.axes1, &#039;XData&#039;,xdata, &#039;YData&#039;,ydata, ...);&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>@Florin &#8211; you probably have the same problem as Cemil and the solution is similar. In your slider callback, instead of using a simple <b><i>imagesc</i></b>, directly specify the parent axes:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">imagesc<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Parent'</span>,handles.<span style="">axes1</span>, <span style="color:#A020F0;">'XData'</span>,xdata, <span style="color:#A020F0;">'YData'</span>,ydata, <span style="color: #F0F;">...</span><span style="color: #080;">&#41;</span>;</pre></div></div>]]></content:encoded> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk: basic
Theme:              b7666
Template:           single
-->
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: undocumentedmatlab.com @ 2012-05-18 22:18:17 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:          blog/continuous-slider-callback/feed/_index.xml_gzip
Caching:            enabled
Status:             not cached
Creation Time:      0.686s
Header info:
X-Pingback:         http://undocumentedmatlab.com/blog/xmlrpc.php
Set-Cookie:         wpgb_visit_last_php-default=1337404697; expires=Sun, 19-May-2013 05:18:17 GMT; path=/
Link:               <http://undocumentedmatlab.com/?p=1052>; rel=shortlink
Content-Type:       text/xml; charset=UTF-8
Last-Modified:      Sat, 19 May 2012 05:18:17 GMT
Vary:               Accept-Encoding, Cookie
Expires:            Sat, 19 May 2012 06:18:17 GMT
Pragma:             public
Cache-Control:      public, must-revalidate, proxy-revalidate
Etag:               148e4969d01381f8c5b8b774c4abde8b
Content-Encoding:   gzip
-->
