Can a gui read a list from a file, open a new window containing that list, and allow the user to select items from that list? If so, what commands/topics should I study?

Want to create a GUI run-time listing (upfront there are an unknown # of items with unknown labels) using items read from a file during execution & allow user to select items from this dynamic list.

Answers (1)

doc menu
doc textscan

4 Comments

I worked on this and came up with something, I imagine it is not the best way to do this but it seems to work.
I created the attached file called select_channels.m
Then I ran it by typing:
global channels; names = {'Channel #1'; 'Channel #2'; 'Channel #3'; 'Channel #4'}; select_channels(names); names(channels)
It opens a window with all the channel names listed. Using control-left_mouse, you select the channels desired. Type names(channels) in the command window to see what channels were selected interactively.
Try this:
List = {'Channel#1' , 'Channel#2' , 'Channel#3', 'Channel#4'};
Choice = menu('Choose a channel' , List{1:length(List)})
selectedChannel = List{Choice}
The menu command works only if you have one channel to choose. In my case, I want to select anywhere from 1 to all 4 channels. "select_channels.m" allows you to choose one or multiple channels, just highlight all the channels you need.
I didn't notice that. See listdlg , It let's you make multiple selection.

This question is closed.

Products

Asked:

on 17 Mar 2014

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!