%% Code Response to Pop-up Menu Selection
% Create a pop-up menu that displays a list of choices when clicked.  Use a callback function to determine the list item selected by the user and display the selection in the MATLAB Command Window.

f = figure;
c = uicontrol(f,'Style','popupmenu');
c.Position = [20 75 60 20];
c.String = {'Celsius','Kelvin','Fahrenheit'};
c.Callback = @selection;

%

function selection(src,event)
        val = c.Value;
        str = c.String;
        str{val};
        disp(['Selection: ' str{val}]);
end

% Copyright 2018 The MathWorks, Inc.