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.

回答 (1 件)

doc menu
doc textscan

4 件のコメント

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.
Dishant Arora
Dishant Arora 2014 年 3 月 19 日
編集済み: Dishant Arora 2014 年 3 月 19 日
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.

この質問は閉じられています。

製品

質問済み:

2014 年 3 月 17 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by