Pop UP menu in GUIDE
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello i am developping an interactive GUI for my identification method which is of ellipsoidal type. But my issue is pretty trivial to GUIDE developpers. i have a problem with following:
i want to create a popup menu with three options, now i know that i should change/populate the needed script to be executed in the Callback function "in the switch cases". what i wanna do is for example when a user chooses a case 1, a m file function gets executed. similarly second case, a second function gets executed with a different purpose.
let's say my function is called RLS.m, second LS.m, and the thrid is ESM.m so this did not work
function popupmenu1_Callback(hObject, eventdata, handles)
str = get(hObject, 'String'); val = get(hObject,'Value');
switch str{val}; case 'Ellipsoidal Set Estimation' % User selects peaks. feval('ESM'); case 'Recursive Least Square Estimation' % User selects membrane. feval('RLS'); : : end % Save the handles structure. guidata(hObject,handles)
help would be appreciated
0 Kommentare
Antworten (2)
Arthur
am 20 Mär. 2012
feval uses function handles rather than the name of the function. But I think you don't need feval at all. If your functions are on the matlab search path, you can just call the function directly. Also, you do not need to read the String of your popup. I usually just use the value of the popup, which is easier to program, and allows you to change the String of the popup while the GUI is running.
I suggest to try this:
function popupmenu1_Callback(hObject, eventdata, handles)
val = get(hObject,'value');
switch val
case 1
RLS;
case 2
LS;
case 3
ESM;
end
Sam
am 20 Mär. 2012
3 Kommentare
Arthur
am 21 Mär. 2012
Your switch uses 'val', which will have value 1,2 or 3, whereas your cases are still strings. Change the cases to numbers and it should work. Also, you might want to include an 'otherwise' statement in your switch. This makes it easier to debug.
try this:
function popupmenu1_Callback(hObject, eventdata, handles)
str = get(hObject, 'String');
val = get(hObject,'Value');
% Set current data to the selected data set.
switch val;
case 1 % User selects peaks.
Ellipsoidal_Algorithm;
case 2% User selects membrane.
return;
otherwise
error('Invalid value');
end
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!