How to use a edit box on a GUI
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Amanda
el 1 de Dic. de 2022
Comentada: Amanda
el 1 de Dic. de 2022
I am trying to use a edit box to be able to put a number in the box and then use a push button and it will take that number and use it. I am doing this for a robot maze and im trying to write a number of steps in the edit box and the when i push the button it takes that many steps in the maze. I'm suppose to use the a function that has already been created 'walk' to do this but i have no idea how to.
function steps_made_successfully = walk(number_of_steps)
steps_made_successfully = 0;
for i=1:number_of_steps
if is_clear()steps_made_successfully = steps_made_successfully + 1;
move_forward();
else
break;
end
end
end
2 comentarios
Benjamin Thompson
el 1 de Dic. de 2022
Is this a GUIDE GUI or AppDesigner GUI? You may want to attach your current work for the Community to reference.
Respuesta aceptada
Kevin Holly
el 1 de Dic. de 2022
Add a callback to the ninth_button that reads the value in the 'eighth_button' edit field and places it as an input to the walk function.
ninth_button.Callback = 'number_of_steps = str2num(eighth_button.String); walk(number_of_steps)';
Más respuestas (0)
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!