Calling a pushbutton inside a GUI

3 ビュー (過去 30 日間)
Paul
Paul 2011 年 9 月 13 日
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 Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by