0

I'm writing a Gui in matlab but I have a problem with popups. This is the code I wrote:

str=get(handles.popupmenu1, 'String');
val=get(handles.popupmenu1, 'Value');
switch str{val}
    case 1
        val=Normal;
    case 2
        val=t;
end
handles.val = val;
guidata(handles.figure1, handles);

I want to use the string in the popup in another function as its input. But matlab selects both the values, Normal and t, so that the other function (garchfit) does not work. How can I tell Matlab to get just the String the user selects? Thank you

Fodex
  • 55
  • 1
  • 7

1 Answers1

0

You are redefining val in a strange way here. You probably want to change the assignments to val in the switch statement to some other variable. Depending on what doing on here, you might not need that switch statement at all. The selected string from the popup menu is str{val}. You can use that as the input to garchfit.

garchfit(str{val})
Molly
  • 13,240
  • 4
  • 44
  • 45