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
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
2017 年 7 月 19 日
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 Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!