Activate radio button from another radio button

3 ビュー (過去 30 日間)
Max Kalinin
Max Kalinin 2013 年 12 月 6 日
コメント済み: Max Kalinin 2013 年 12 月 6 日
Im new to GUIDE but have made it through the simple stuff of how to get input from buttons and have them display things and alter the properties of other objects. I am however having issues trying to toggle a radio button from a function of another. I have tried setting its value to change its state but that is all it does. It does not execute the code within the function. I in turn figured I can just call the handleName_Callback(Hobject, eventdata, handles); within the function to get it to activate. The problem is I am not sure what the input variables are exactly. I tried entering the handle for the radio button itself, then the handle for the figure into Hobject but they both result in errors. I have been leaving the other fields blank entirely because I have no idea what they are. Here is what I have for the function Callback (I havent touched the handles structure).
%first function
function function1_Callback(hObject, eventdata, handles)
option = get(hObject, 'Value');
if(option ~= 1)
%This is where I want to execute function2
function2_Callback(handles.function2); %Please let me know what this should be
Thanks in advance

採用された回答

Simon
Simon 2013 年 12 月 6 日
Hi!
Usually the first argument is the handle to the object whose callback you are calling. You can get this from guihandles. This gives you a struct. You get the specific handle if you know the specific tag.
The remainder you just pass along:
%first function
function function1_Callback(hObject, eventdata, handles)
option = get(hObject, 'Value');
if(option ~= 1)
%This is where I want to execute function2
h = guihandles;
h_function2 = h.TagName;
function2_Callback(h_function2, eventdata, handles);
I hope it works, I didn't have a chance to test it.
  1 件のコメント
Max Kalinin
Max Kalinin 2013 年 12 月 6 日
Thank you so much for this quick answer. Worked perfectly! After about 4 hours of trying to figure it out... Digital hug for you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInstall Products についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by