switch case in GUI pop-up menu
조회 수: 6 (최근 30일)
이전 댓글 표시
I've a pop-up menu with 5,10,15,20 the contents in that menu. using switch I've created this, what changes i need to do with this statement?
val=get(hObject,'value');
switch val
case '5'
n=5;
case '10'
n=10;
case '15'
n=15;
case '20'
n=20;
end
handles.n = val;
guidata(hObject, handles);
where it represents number of output images. I'm suppose to get 5 images at output if user selects 5 in pop-up menu, 10 images if 10 is selected and so on.... But I'm getting only 1 image if i select 5, 2 images if 10, 3 if 15... like that, what's wrong in my switch statement? any appropriate answer is appreciable.
댓글 수: 2
Vishal Rane
2013년 3월 28일
Can't say anything based on the code you have given. Can you share the code where "n" is actually used ?
답변 (1개)
Jing
2013년 3월 28일
It looks like you're using the selected index(the value you get is index...) of the popup menu, not the selected content for getting the output. When you use switch, it should be like this:
switch val
case 1
n=5;
case 2
n=10;
case 3
n=15;
case 4
n=20;
end
handles.n = n; %supposed handles.n is what you use to get output images.
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!