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 Comment

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.

Sign in to comment.

Answers (1)

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.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Asked:

on 19 Jul 2017

Answered:

on 19 Jul 2017

Community Treasure Hunt

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

Start Hunting!