problem with radiobuttons and If loop in GUI
이전 댓글 표시
Hello all,
I'm workin on a project with GUI but I'm not well experienced. I have different radiobuttons in 2 pannels and depending on the user selection, a certain loop is executed when he clicks a pushbutton.
Here is a sample of what the code:
function uipanel2_SelectionChangeFcn(hObject, eventdata, handles) global exchanger_selection
if hObject ==handles.radiobutton1
exchanger_selection=1;
elseif hObject ==handles.radiobutton2
exchanger_selection=2;
elseif hObject ==handles.radiobutton3
exchanger_selection=3;
end
.
function uipanel7_SelectionChangeFcn(hObject, eventdata, handles) global design_selection
if hObject ==handles.radiobutton6
design_selection=1;
elseif hObject ==handles.radiobutton7
design_selection=2;
end
.
function pushbutton9 _Callback(hObject, eventdata, handles) global exchanger_selection _selection
if all(all(exchanger_selection==1) && all(design_selection==1))
...end
elseif all(all(exchanger_selection==1) && all(design_selection==2))
...end
elseif all(all(exchanger_selection==2) && all(design_selection==1))
...end
elseif all(all(exchanger_selection==2) && all(design_selection==2))
...end
Now inside each if statement I have a lengthy loop includes for loops and if statements. The problem is when I click on certain group of radio buttons then the push button, GUI doesn't excute the right loop, instead it always executes the last loop skipping the conditions.
In the if condition statements I have also tried using & with 'all' and without 'all', I used isequal and I tried switch case but the problem still the same.
I would be thankful if someone can help me figure out the source of the problem.
Thanks in advanced.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!