Make PushButton select a field within structure

Hello,
I'm building a GUIDE that would have a pushbutton allow the user the option to select a specific field within a variable (contains a 1x100 structure w 5 fields).
The user will push the button and all the data in the chosen field will appear and a single one will be selected by the user to be used in a different function.
Is there a way to do this? Please let me know,
Thanks!

1 件のコメント

Jan
Jan 2017 年 7 月 19 日
Yes, there is a way. But waht exactly is your question? How can we assist you? Start GUIDE and try to implement it. Then ask a specific question if a problem occurres.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 7 月 19 日

0 投票

fn = fieldnames(TheStruct);
choice = menu('Pick a field', fn{:});
if choice >= 0 & choice <= length(fn)
values = {TheStruct.(fn{choice})};
...
end
The way to proceed from there would depend upon the data type of the values, and upon the way you want the user to select one out of the 100 values. Choosing 1 out of 100 distinct values is messy unless you want the user to just select the index.

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

質問済み:

2017 年 7 月 19 日

回答済み:

2017 年 7 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by