MATLAB: (App Designer) Dropdown menu detect variables in workspace.

app designer

I'm try to familiar myself with apps designer. How to create a dropdown menu with the list of variables in workspace. so, user only choose their selected variable/dataset.

Best Answer

Yes, it is possible. Here is one way. Add a drop-down menu to the app. In the COMPONENT BROWSER right-click app.UIFigure and add a startupFcn callback for figure object. You can define the newly created function like this
function startupFcn(app)
vars = evalin('base', 'whos');
cell_array = cell(size(vars));
for i=1:length(vars)
cell_array{i} = vars(i).name;
end
app.DropDown.Items = cell_array;
end
where DropDown is the name of your drop-down menu. Now start the app, the drop-down menu will enlist all the variables from the workspace.