<?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: Advanced MATLAB: ButtonDownFcn</title>
	<atom:link href="http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/</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>Thu, 16 Feb 2012 22:44:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Faisal</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-14291</link>
		<dc:creator>Faisal</dc:creator>
		<pubDate>Tue, 01 Nov 2011 11:35:23 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-14291</guid>
		<description>hello,
Actually i am displaying a 300 by 300 point using a scatter subplot along a picture on the background on subplot. now what i need is when i click a point on scatter point i will display the actual point used to plot (not the axis). The code which i am using only display the axis of the plot not the actual value used to plot.
my code is

&lt;pre&gt;

set(gca,&#039;YDir&#039;,&#039;reverse&#039;)
subplot(1,2,1),
pomegranate = imread(train_data_desc(i).gbd_name);
imshow(pomegranate(:,:,1));
hold on
OrigImg = scatter(train_data_desc(i).gbd_pos(:,2),train_data_desc(i).gbd_pos(:,1),15,(cw{i}/15)&#039;);
set(OrigImg,&#039;buttondownfcn&#039;,@call_OrigImg_fun);
title(&#039;Query Image&#039;)

for j=1:size(train_data_desc(i).gbd_pos,1)
    
 text(train_data_desc(i).gbd_pos(j,2),    train_data_desc(i).gbd_pos(j,1), num2str(j));
end

function call_OrigImg_fun(gcbo,eventdata,handles)
    
    disp(get(gca,&#039;Currentpoint&#039;));

&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>hello,<br />
Actually i am displaying a 300 by 300 point using a scatter subplot along a picture on the background on subplot. now what i need is when i click a point on scatter point i will display the actual point used to plot (not the axis). The code which i am using only display the axis of the plot not the actual value used to plot.<br />
my code is</p>
<pre>

set(gca,'YDir','reverse')
subplot(1,2,1),
pomegranate = imread(train_data_desc(i).gbd_name);
imshow(pomegranate(:,:,1));
hold on
OrigImg = scatter(train_data_desc(i).gbd_pos(:,2),train_data_desc(i).gbd_pos(:,1),15,(cw{i}/15)');
set(OrigImg,'buttondownfcn',@call_OrigImg_fun);
title('Query Image')

for j=1:size(train_data_desc(i).gbd_pos,1)

 text(train_data_desc(i).gbd_pos(j,2),    train_data_desc(i).gbd_pos(j,1), num2str(j));
end

function call_OrigImg_fun(gcbo,eventdata,handles)

    disp(get(gca,'Currentpoint'));
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-14196</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Wed, 20 Jul 2011 18:46:35 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-14196</guid>
		<description>@Jim and griffin,

In general, it is better easier, and more in model to call functions, not scripts.  It is easy to convert a script to a function.  I recommend you go that route.  It will help you here and in general.  The function could just CALL your script.

Doug</description>
		<content:encoded><![CDATA[<p>@Jim and griffin,</p>
<p>In general, it is better easier, and more in model to call functions, not scripts.  It is easy to convert a script to a function.  I recommend you go that route.  It will help you here and in general.  The function could just CALL your script.</p>
<p>Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Griffin</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-14186</link>
		<dc:creator>Griffin</dc:creator>
		<pubDate>Thu, 07 Jul 2011 19:23:58 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-14186</guid>
		<description>I am attempting to do the something very similar:
I have files of .avi movies typically 40 seconds in length each. I want to make a simple line plot of the movie. The y axis would be empty and the x axis would be the length of the movie in seconds.

y = 0
plot([startOfMovie, endOfMovie], [y, y])

Each movie is a set of 10 repetition exercise. I want the user to be
able to use the plot interactively to identify the start and stop time
of each rep in a GUIDE gui.

by default the plot should have a line that represents the movie in seconds:

________________________
              seconds


then after the user identifies start and stop times of each rep the
plot. For example, rep1 started at 5.5 secs and ended at 6.3 secs. So it will look like this:

_____-___-___-____-___-____


With each dash representing a starting and end time of a rep. (it doesn&#039;t have to be a dash, it could just be a colored section or something else) Is
something like this possible in matlab? I also need to be able to
store each of those data points.</description>
		<content:encoded><![CDATA[<p>I am attempting to do the something very similar:<br />
I have files of .avi movies typically 40 seconds in length each. I want to make a simple line plot of the movie. The y axis would be empty and the x axis would be the length of the movie in seconds.</p>
<p>y = 0<br />
plot([startOfMovie, endOfMovie], [y, y])</p>
<p>Each movie is a set of 10 repetition exercise. I want the user to be<br />
able to use the plot interactively to identify the start and stop time<br />
of each rep in a GUIDE gui.</p>
<p>by default the plot should have a line that represents the movie in seconds:</p>
<p>________________________<br />
              seconds</p>
<p>then after the user identifies start and stop times of each rep the<br />
plot. For example, rep1 started at 5.5 secs and ended at 6.3 secs. So it will look like this:</p>
<p>_____-___-___-____-___-____</p>
<p>With each dash representing a starting and end time of a rep. (it doesn&#8217;t have to be a dash, it could just be a colored section or something else) Is<br />
something like this possible in matlab? I also need to be able to<br />
store each of those data points.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim O' Doherty</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-14156</link>
		<dc:creator>Jim O' Doherty</dc:creator>
		<pubDate>Tue, 31 May 2011 10:21:01 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-14156</guid>
		<description>Great video,
On my code, I have 2 different axes. Is it possible to modify the above to simply run an .m file rather than a function? I&#039;d like to be able to run different scripts depending on which axes the user clicks on. Even using the functions I can&#039;t seem to differentiate between the axes

I&#039;ve tried the following:

axes(handles.axes3)
h(1)=imshow(image_1, [])
setappdata(gcf,&#039;bdfcnhandle&#039;,@load_stuff);
        
axes(handles.axes4)
h(2)=imshow(image_2, [])
setappdata(gcf,&#039;bdfcnhandle&#039;,@load_stuff2);

 set(h,&#039;buttondownfcn&#039;,&#039;feval(getappdata(gcf,&#039;&#039;bdfcnhandle&#039;&#039;));&#039;);%


function load_stuff(hObject, eventdata, handles)
X=1

function load_stuff2(hObject, eventdata, handles)
X=2</description>
		<content:encoded><![CDATA[<p>Great video,<br />
On my code, I have 2 different axes. Is it possible to modify the above to simply run an .m file rather than a function? I&#8217;d like to be able to run different scripts depending on which axes the user clicks on. Even using the functions I can&#8217;t seem to differentiate between the axes</p>
<p>I&#8217;ve tried the following:</p>
<p>axes(handles.axes3)<br />
h(1)=imshow(image_1, [])<br />
setappdata(gcf,&#8217;bdfcnhandle&#8217;,@load_stuff);</p>
<p>axes(handles.axes4)<br />
h(2)=imshow(image_2, [])<br />
setappdata(gcf,&#8217;bdfcnhandle&#8217;,@load_stuff2);</p>
<p> set(h,&#8217;buttondownfcn&#8217;,'feval(getappdata(gcf,&#8221;bdfcnhandle&#8221;));&#8217;);%</p>
<p>function load_stuff(hObject, eventdata, handles)<br />
X=1</p>
<p>function load_stuff2(hObject, eventdata, handles)<br />
X=2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13600</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Tue, 01 Jun 2010 20:23:44 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13600</guid>
		<description>@chin

There is a closerRequestfcn.  Put close(gcf) in it.

Doug</description>
		<content:encoded><![CDATA[<p>@chin</p>
<p>There is a closerRequestfcn.  Put close(gcf) in it.</p>
<p>Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chin</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13599</link>
		<dc:creator>chin</dc:creator>
		<pubDate>Tue, 01 Jun 2010 14:47:26 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13599</guid>
		<description>I have a question. I created a couple of figures in an interface I am testing out and I want it to close when I click on the x on the top rite hand of corner of the figure for any figure. How would i go about that doing that. I am very new to matlab. Thank you</description>
		<content:encoded><![CDATA[<p>I have a question. I created a couple of figures in an interface I am testing out and I want it to close when I click on the x on the top rite hand of corner of the figure for any figure. How would i go about that doing that. I am very new to matlab. Thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcel</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13456</link>
		<dc:creator>Marcel</dc:creator>
		<pubDate>Thu, 04 Mar 2010 21:51:36 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13456</guid>
		<description>Alright, I think I found a solution...
it turns out the values from the rbbox command need to be scaled according to the axes limits and the total size of the axes object:
&lt;pre&gt;
final_rect = rbbox()
xl = xlim(ax)
yl = ylim(ax)

ap = get(ax, &#039;Position&#039;)

ws = (xl(2) - xl(1)) / ap(3)
hs = (yl(2) - yl(1)) / ap(4)

box = [ pt(1, 1:2) final_rect(3) * ws final_rect(4) * hs ]
&lt;/pre&gt;

So basically, ws and hs are scale factors that scale a given point in the figure (which is what  rbbox returns, i guess) to a point in the image object. Hope this helps someone.</description>
		<content:encoded><![CDATA[<p>Alright, I think I found a solution&#8230;<br />
it turns out the values from the rbbox command need to be scaled according to the axes limits and the total size of the axes object:</p>
<pre>
final_rect = rbbox()
xl = xlim(ax)
yl = ylim(ax)

ap = get(ax, 'Position')

ws = (xl(2) - xl(1)) / ap(3)
hs = (yl(2) - yl(1)) / ap(4)

box = [ pt(1, 1:2) final_rect(3) * ws final_rect(4) * hs ]
</pre>
<p>So basically, ws and hs are scale factors that scale a given point in the figure (which is what  rbbox returns, i guess) to a point in the image object. Hope this helps someone.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcel</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13455</link>
		<dc:creator>Marcel</dc:creator>
		<pubDate>Thu, 04 Mar 2010 06:34:46 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13455</guid>
		<description>Doug,
here&#039;s what I&#039;ve come up with to reproduce the problem:
1. Create a simple GUI consisting just of a figure with an axes object in it. I used GUIDE for this.
2. In the GUI&#039;s OpeningFcn, I create an image object with the axes object as the parent, and set its buttondownfcn to a simple handler that draws a rectangle in what I would consider two reasonable ways. This looks as follows:

&lt;pre&gt;
function imclk(hObject, eventdata)
ax = get(hObject, &#039;Parent&#039;);
pt = get(ax, &#039;CurrentPoint&#039;);
final_rect = rbbox();
otherbox = [ pt(1, 1:2) final_rect(3:4) ];
rectangle(&#039;Position&#039;, final_rect, &#039;Parent&#039;, ax);
rectangle(&#039;Position&#039;, otherbox, &#039;Parent&#039;, ax);

function imclktst_OpeningFcn(hObject, eventdata, handles, varargin)

% Choose default command line output for imclktst
handles.output = hObject;

im = imshow(&#039;test.jpg&#039;, &#039;Parent&#039;, handles.axes1) %this works best with a picture of Don Rickles.
set(im, &#039;ButtonDownFcn&#039;, @imclk );

% Update handles structure
guidata(hObject, handles);
&lt;/pre&gt;

Unfortunately, the rectangles don&#039;t end up in the right spot, and I&#039;m not quite sure how to proceed. I&#039;d love suggestions!</description>
		<content:encoded><![CDATA[<p>Doug,<br />
here&#8217;s what I&#8217;ve come up with to reproduce the problem:<br />
1. Create a simple GUI consisting just of a figure with an axes object in it. I used GUIDE for this.<br />
2. In the GUI&#8217;s OpeningFcn, I create an image object with the axes object as the parent, and set its buttondownfcn to a simple handler that draws a rectangle in what I would consider two reasonable ways. This looks as follows:</p>
<pre>
function imclk(hObject, eventdata)
ax = get(hObject, 'Parent');
pt = get(ax, 'CurrentPoint');
final_rect = rbbox();
otherbox = [ pt(1, 1:2) final_rect(3:4) ];
rectangle('Position', final_rect, 'Parent', ax);
rectangle('Position', otherbox, 'Parent', ax);

function imclktst_OpeningFcn(hObject, eventdata, handles, varargin)

% Choose default command line output for imclktst
handles.output = hObject;

im = imshow('test.jpg', 'Parent', handles.axes1) %this works best with a picture of Don Rickles.
set(im, 'ButtonDownFcn', @imclk );

% Update handles structure
guidata(hObject, handles);
</pre>
<p>Unfortunately, the rectangles don&#8217;t end up in the right spot, and I&#8217;m not quite sure how to proceed. I&#8217;d love suggestions!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13451</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Wed, 03 Mar 2010 15:40:41 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13451</guid>
		<description>@Marcel,

I am not sure.  Please send the simplest version of your code that exhibits this behavior with clear reproduction steps.  I will see what I can do.  It might make a good video!

Doug</description>
		<content:encoded><![CDATA[<p>@Marcel,</p>
<p>I am not sure.  Please send the simplest version of your code that exhibits this behavior with clear reproduction steps.  I will see what I can do.  It might make a good video!</p>
<p>Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcel</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13450</link>
		<dc:creator>Marcel</dc:creator>
		<pubDate>Wed, 03 Mar 2010 00:56:13 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13450</guid>
		<description>I&#039;d like to have a user select a rectangular area of an image using the rbbox method. I have a GUI (from GUIDE) with an axes control into which I can render the image (using imshow), and I register a buttondownfcn callback for the image object. When the user clicks, I start an rbbox in that callback. Unfortunately the values I get from rbbox are apparently scaled by some amount - when I then draw a rectangle using the return value from rbbox, it ends up somewhere else completely, and if I just use the width/height of the rbbox with the initial point, the size seems to be scaled by some constant factor.
I imagine this has to do with the rbbox call not using the right set of axes somehow, but I&#039;m not sure how to fix that. Any suggestions?</description>
		<content:encoded><![CDATA[<p>I&#8217;d like to have a user select a rectangular area of an image using the rbbox method. I have a GUI (from GUIDE) with an axes control into which I can render the image (using imshow), and I register a buttondownfcn callback for the image object. When the user clicks, I start an rbbox in that callback. Unfortunately the values I get from rbbox are apparently scaled by some amount &#8211; when I then draw a rectangle using the return value from rbbox, it ends up somewhere else completely, and if I just use the width/height of the rbbox with the initial point, the size seems to be scaled by some constant factor.<br />
I imagine this has to do with the rbbox call not using the right set of axes somehow, but I&#8217;m not sure how to fix that. Any suggestions?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

