Specify Callbacks in Function Calls matlab
来源:互联网 发布:电脑连不上网络 感叹号 编辑:程序博客网 时间:2024/05/19 09:39
Specify a component callback property value as one of the following:
A string that contains one or more MATLAB ortoolbox commands to evaluate
A handle to a function that is within scope when theGUI is running
A cell array containing a string function name ora function handle, plus optional strings, constants, or variable namesfor arguments
Use String Callbacks
You can concatenate commands in a string callback. This one,for example, adds a title to the plot it creates.
set(hb,'Callback',... 'plot(myvar,''--m''); title(''String Callback'')')
Use Function Handle Callbacks
Here is an example of declaring a callback when defininga uicontrol:
figureuicontrol('Style','slider','Callback',@display_slider_value)
Hereis the definition of the function in the GUI code file. The callbackprints the value of the slider when you adjust it:
function display_slider_value(hObject,eventdata)disp(['Slider moved to ' num2str(get(hObject,'Value'))]);
Whenyou click an arrow on the slider, the output of the function lookslike this:
Slider moved to 0.01Slider moved to 0.02
Use Cell Arrays with Strings.
The following cellarray callback defines a function name as a quoted string,'pushbutton_callback',and two arguments, one a variable name and one a string:
myvar = rand(20,1);set(hb,'Callback',{'pushbutton_callback',myvar,'--m'})
Thesetwo arguments are followed by whatever arguments you include whenyou specify the callback for the component. Code to execute'pushbutton_callback' mightlook like this:
function pushbutton_callback(hObject, eventdata, var1, var2)plot(var1,var2)
Use Cell Arrays with Function Handles.
You canspecify a callback function using a function handle insteadof using a function name.
The following variation uses afunction handle to specify pushbutton_callback asthe callback routine to be executed when a user clicksPlotline.
figure;hb = uicontrol('Style','pushbutton',... 'String','Plot line')set(hb,'Callback',{@pushbutton_callback,myvar,'--m'})
As above, the callback is in a file named pushbutton_callback.m,which contains code such as this:
function pushbutton_callback(hObject, eventdata, var1, var2)plot(var1,var2)
- Specify Callbacks in Function Calls matlab
- Function Pointers and Callbacks in C
- roots function in MATLAB
- isnan function in matlab
- find function in matlab
- function handle in MATLAB
- Tool to trace local function calls in Linux
- the function calls text
- •Monitoring Function Calls
- ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Con
- Visualize function calls with Graphviz
- AsyncCalls2.95 Asynchronous function calls
- Initialization calls in Linux
- Asynchronous Calls in .Net
- Use the edge function in matlab
- How to call Matlab function in C++
- fuck the function “reshape” in matlab
- size, length, numel function in matlab
- HDU-3435 A new Graph Game
- How to compare two cells value in Grid via Compare Validator?
- 程序设计重点在于设计好的数据结构
- Qt vs MFC (Qt和MFC的战争)
- MyEclipse 常用快捷键
- Specify Callbacks in Function Calls matlab
- mfc 中 Tab Control 控件的使用
- java中常见的设计模式
- Linux网络性能优化方法简析
- mysql点点滴滴
- android 输入法联想问题
- 电影《好好先生》
- 接口漫谈
- jboss内存大小改动