popupmenu in GUI, string call backs.

3 ビュー (過去 30 日間)
James Hendren
James Hendren 2013 年 7 月 11 日
コメント済み: sana saleeme 2016 年 5 月 9 日
So in my gui I have 3 pop-up menus: media, sample, and model. The media has selctions: isotropic and anisotropic the sample has selections: semi-infinite, infinite, and bulk the model has selections:Pseudo-Eps1&2,Psi and Delta, Rss, Rpp, Tss, Tpp, andMueller Matrix
Each of the these selections has particular coding of course. My problem is I need to select these in any manner and then use a pushbutton "Load Data" to load a .dat file.
Questions: How to go about programming the gui that it calls back any combination of these selections. As much detail as possible would be greatly appreciated

採用された回答

Evan
Evan 2013 年 7 月 11 日
編集済み: Evan 2013 年 7 月 11 日
Are you using GUIDE for this GUI? If so, you'll need to access the "value" property of each of your popupmenus from within your pushbutton callback. Based on those values, you can make settings from within a switch/case or if/elseif structure. Your basic form will be:
media_value = get(handles.media_popupmenu,'Value');
sample_value = get(handles.sample_popupmenu,'Value');
model_value = get(handles.model_popupmenu,'Value');
These will all return scalar values which represent the string you've selected in the menus based on its order in the entire list of string arguments.
In order to make you code more readable, you could perhaps also get the string values for each menu and then reference them based on the value. So after each of those get functions you'd do something like:
media_list = get(handles.media_popupmenu,'String');
selection = media_list{media_value};
And so on for the rest of you menus. Then selection would be the exact string that your user selected.
  2 件のコメント
James Hendren
James Hendren 2013 年 7 月 11 日
I am using GUIDE as it is an extensive interface. I am unclear though. Does the 'Value" return the selection from a list or would the "string" return it?
Evan
Evan 2013 年 7 月 11 日
編集済み: Evan 2013 年 7 月 11 日
Actually, neither does. Value returns the index of your selection. So if you have a popupmenu with the items Red, Green, and Blue, and your user selects Blue, 'Value' will return v=2. If you ask for string, you won't just get Blue, you'll get the entire list: list={'Red','Green','Blue'}. To get the choice that the user selected, you have to call selection=list{v}

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

その他の回答 (1 件)

Robert Cumming
Robert Cumming 2013 年 7 月 11 日
FYI: The string returns the items, and value is the item selected.
  2 件のコメント
James Hendren
James Hendren 2013 年 7 月 11 日
thank you
sana saleeme
sana saleeme 2016 年 5 月 9 日
as in above case he get the string from popup menu.how i can get the floating numbers from popup menu?please tell me Evan.

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

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by