MATLAB: Gui interface and variables

gui pop up menu variables workspace

hi I am developing and user interface I want to select by means of a pop menu the value of a variable function popupmenu1_Callback(velocity, eventdata, handles) vel=get(velocity,'Value')
how I can do it?. I want that the value of the string in the pop menu becomes the value of the variable vel and besides, I want this variable in the workspace to do more operations
in the two lines written vel gets the value of the position and is not available in the workspace
thanks

Best Answer

The structure to use popupmenu is something like this
function popupmenu1_Callback(hObject, eventdata, handles)
option=get(handles.popupmenu1,'value'); %Now Vel has the number of option
c=get(handles.popupmenu1,'String');
your_string=c{option} %your_string has the string value
assignin ('base','your_string',your_string) %sends it to workspace
guidata(hObject, handles);