How can I call a matlab function from a pushbutton callback from matlab gui ? Elaborate in details pls.

2 次查看(过去 30 天)
I want to call a simple matlab function which returns a value. The function needs to be called when the pushbutton is clicked from the gui. I have already created the gui using guide. I just need to call the working function on the button-click. Kindly give me the details how can I do that ?

回答(1 个)

Walter Roberson
Walter Roberson 2014-3-20
In the callback code, put in the call to the function, passing in appropriate arguments, just like if you had typed it on the command line. For example
function button1_callback(hObject, event, handles)
result = my_function(handles.parameter1_value);
set(handles.output_box, num2str(result);
end

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by