Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>From the result you got for the button callback, it appears that the callback has been created in the following way (just for example):</p> <pre><code>hButton = uicontrol(...,'Callback',{@button_callback,1,1,[1:6]}); </code></pre> <p>where the callback function <code>button_callback</code> is defined as follows:</p> <pre><code>function button_callback(hObject,eventdata,a,b,c) ... end </code></pre> <p>Notice that there are <a href="http://www.mathworks.com/help/matlab/creating_guis/write-callbacks-using-the-programmatic-workflow.html#brqow8p" rel="nofollow noreferrer"><em>two extra arguments</em> in the input argument list</a> for the callback function: <code>hObject</code> (the handle of the object invoking the callback) and <code>eventdata</code> (a structure of event data).</p> <p>If you want to invoke the function handle with the 3 additional arguments that should be passed to it (<code>1</code>, <code>1</code>, and a 1-by-6 array), you need to also pass arguments for the <code>hObject</code> and <code>eventdata</code> inputs. Here's how calling the function would look (using your variable <code>ans</code>):</p> <pre><code>ans{1}(hButton,[],ans{2:end}); </code></pre> <p>You first get the function handle from the cell array (<code>ans{1}</code>) then <a href="http://www.mathworks.com/help/matlab/matlab_prog/calling-a-function-using-its-handle.html" rel="nofollow noreferrer">call it using parentheses as you would any other function</a>. For <code>hObject</code> you can pass the handle to the uicontrol object (or an empty value if it isn't needed), and for <code>eventdata</code> you can just pass an empty value. The additional values are then taken from the cell array as a <a href="http://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html" rel="nofollow noreferrer">comma-separated list</a> (<code>ans{2:end}</code>) and each is passed to the function as a separate additional argument.</p>
 

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