How to fix uicontrol callback error and retrieve the status of a pushbutton from a callback function ?
古いコメントを表示
I have a GUI where I am using a pushbutton which says start test. The callback function for this pushbutton is in the gui code. I want the funtion to return a binary value indicating whether the button is pressed or not.
- If it is pressed it should display a message and set it back to 0 for the next time it will be pressed.
- The above point of resetting or overwriting, I have incorporated in my main matlab code and the gui one expecting atleast one to work
However when I run the main code it shows me an error at that line of code where I try to compare the the status of the pushbutton to 1 or 0
And when i run the gui code it shows me "Error while evaluating uicontrol Callback", "Error in ==> @(hObject,eventdata)
How can I solve this error? I have tried using handles and hObject but maybe i am not using them right.
Can someone help me just to display the status of the pushbutton?
function PbStartTest_Callback(hObject,eventdata, handles)
guidata(hObject,handles);
button_status = []
button_status == get((button_status.handles,'Value',str2num()));
if button_status == 1
display('test started');
button_status = 0;
end
end
This above code is my gui code and below I am mentioning the error part of my main code
if (GuiElements.PbStartTest.Value ~= 0) % showing error for this line
%Immediately reset the start button
GuiElements.PbStartTestValue = 0;
% After this point it should continue performing the selected test
end
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!