Calling a pushbutton inside a GUI

4 次查看(过去 30 天)
I have a fairly large program I have been working on for my masters project.
There is a pushbutton called braking that does some calculations and at the end I have this below to store the calculated values into two handles.
handles.break_dis=gdist;
handles.break_vel=gvel;
guidata(hObject,handles)
Then in a separate pushbutton called start I have
braking_Callback(hObject, [], handles);
values=handles.break_dis
If I click on the braking button then the start button it works.
If i click directly on the start button it runs the code in the braking button but when it gets to the values=handles.break_dis line it says "Reference to non-existent field 'break_dis'"
I'm not sure what is happening.

采纳的回答

Walter Roberson
Walter Roberson 2011-9-13
After your line
braking_Callback(hObject, [], handles);
you need to add
handles = guidata(hObject);
You got a local copy of the handles structure, so when the handles structure was updated elsewhere in the program, your local copy was not updated. You need to fetch the updated version.

更多回答(0 个)

类别

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