Calling a pushbutton inside a GUI

4 vues (au cours des 30 derniers jours)
Paul
Paul le 13 Sep 2011
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.

Réponse acceptée

Walter Roberson
Walter Roberson le 13 Sep 2011
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.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by