Change Variable Value in a Script through App Designer GUI
Mostrar comentarios más antiguos
Hi, I have a GUI made with App Designer where depending on the option selected from a drop down menu, a particular script will run when a button called 'START' is pressed. I also have several 'Edit Field (Numeric)' where I would want to edit the value of a variable from the GUI. So my issue is how do I change the variable value that is assigned in the script through the GUI's Edit Field.

function STARTButtonPushed(app, event)
if (strcmp(app.SelectTechniqueDropDown.Value,'Option1')
run('script1.m')
elseif (strcmp(app.SelectTechniqueDropDown.Value,'Option2')
run('script2.m')
elseif (strcmp(app.SelectTechniqueDropDown.Value, 'Option3')
run('script3.m')
end
9 comentarios
Dennis
el 6 de Mzo. de 2019
Is there a good reason that you are using scripts instead of functions?
Nick M.
el 7 de Mzo. de 2019
Dennis
el 7 de Mzo. de 2019
Yes, you could pass the variable as function input.
Dennis
el 8 de Mzo. de 2019
Create a simple app with 1 pushbutton and 1 numeric edit field.
The callback of the pushbutton should look like this:
function ButtonPushed(app, event)
MyFcn(app.EditField.Value) %check the name of your EditField if you have more than 1
end
The function can look like this (needs to be on search path):
function MyFcn(MyValue)
disp(MyValue)
end
Nick M.
el 9 de Mzo. de 2019
Dennis
el 11 de Mzo. de 2019
Which size/format does the matrix have? It might be easier to import the matrix from a file.
Nick M.
el 12 de Mzo. de 2019
"...how to allow a user to input a matrix into an edit field?"
Rather than using an edit field, it would be simpler to use a uitable:
Respuestas (0)
Categorías
Más información sobre Develop Apps Using App Designer 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!