Make PushButton select a field within structure
Mostrar comentarios más antiguos
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 comentario
Jan
el 19 de Jul. de 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.
Respuestas (1)
Walter Roberson
el 19 de Jul. de 2017
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.
Categorías
Más información sobre Interactive Control and Callbacks en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!