How do I make an uploaded list of variables names show up in a popup menu?

2 ビュー (過去 30 日間)
Hessam
Hessam 2014 年 10 月 13 日
コメント済み: Geoff Hayes 2014 年 10 月 14 日
In the first part of my GUI, I upload a text file containing a list of names of variables. In the following part of the GUI, I want to have a popup menu listing these variables' names, so that I can choose one of them. How can I do that?
Thanks,
Hessam

回答 (1 件)

Geoff Hayes
Geoff Hayes 2014 年 10 月 14 日
Hessam - you haven't indicated how you have read (uploaded) the data from file, so I'll assume that you have used something like importdata to read that information into a cell array. Once you have done that, you can pass this array to the popup menu object. If you have created your GUI in GUIDE, then you could do something like
varData = importdata('vars.txt');
set(handles.popupmenu1,'String',varData);
where vars.txt is the name of your text file that contains a single column of variable names, and popupmenu1 is the tag of the popup menu object on your GUI.
  2 件のコメント
Hessam
Hessam 2014 年 10 月 14 日
Thank you,
The data is uploaded using
uigetfile
Geoff Hayes
Geoff Hayes 2014 年 10 月 14 日
So presumably you could do something like
[filename,pathname] = uigetfile;
if ischar(filename)
varData = importdata(fullfile(pathname,filename));
set(handles.popupmenu1,'String',varData);
end

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by