How to obtain the text of the selected radio button group in app designer?
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Guandong Wang
el 29 de Mzo. de 2019
Respondida: Kojiro Saito
el 29 de Mzo. de 2019
Dear Community
I'm using the app designer to create a radio button group, and I intended to obtain the 'text' of the selection and save it to work space. Right now my code does save the current selection to workspace, but i notice that it only works if I changed the selection. (ie, if I swich from "choice A" to "choice B" or "choice c" then it will save, but if I left it in default "choice A" it stores nothing)
I was wondering how can I resolve this, or perhaps there is another way to save the selection.
here's my callback function for the radio button group
% Selection changed function: GratingPeriodButtonGroup
function GratingPeriodButtonGroupSelectionChanged(app, event)
selectedButton = app.GratingPeriodButtonGroup.SelectedObject.Text;
app.GratingPeriod = selectedButton ;
end
here's the callback funciton of the pushbutton that save the value to workspace
% Button pushed function: StartButton
function StartButtonPushed(app, event)
assignin('base','GratingPeriod',app.GratingPeriod)
closereq;
end
0 comentarios
Respuesta aceptada
Kojiro Saito
el 29 de Mzo. de 2019
I think you need to add assign an initial value to app.GratingPeriod.
From Code Browser in Code View, click "+" button and add a "StartupFcn" callback function.
Then, write an assignment to app.GratingPeriod.
function startupFcn(app)
app.GratingPeriod = app.Button.Text;
end
Please change app.Button to the actual button name whose value is "choice A".
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!