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 Kommentar

Jan
Jan am 19 Jul. 2017
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 19 Jul. 2017

0 Stimmen

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.

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 19 Jul. 2017

Beantwortet:

am 19 Jul. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by