Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is not necessary to use <code>ginput</code> and extract the coordinates. This is done automatically by an built-in "listener" in the figure-window. You are correct in assuming that you can use the <code>ButtonDownFcn</code> property on the object (line, lineseries, or other handle graphics object).</p> <p>Try to create at simple line from (0,0) to (1,1):</p> <pre><code>hline = line([0,1],[0,1]) %# create line, save handle in hline </code></pre> <p>Then you can set the <code>ButtonDownFcn</code> to, for instance, a function handle to an anonymous function:</p> <pre><code>set( ... hline, ... 'ButtonDownFcn', @(handle,event)(disp(['You clicked on the line!'])) ... ); </code></pre> <p>Now try to click on the line. It should print the text in the command window.</p> <p>The function needs to be able to receive atleast two arguments: (1) the handle of the object itself (the line) and (2) an "event structure". I believe the second argument is just empty when you use line-objects. But your function still needs to receive atleast these two arguments (even if you do not use them).</p> <p>Read more here: <a href="http://www.mathworks.com/help/techdoc/ref/line_props.html" rel="nofollow">http://www.mathworks.com/help/techdoc/ref/line_props.html</a>.</p> <p>You can also use your own function (a named function in a file):</p> <pre><code>set( ... hline, ... 'ButtonDownFcn', @(handle,event)(namedFunction(handle,event)) ... ); </code></pre> <p>... or you can use a struct-array if you (expectedly) have other arguments beyound those two.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload