How to use a edit box on a GUI
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Amanda
am 1 Dez. 2022
Kommentiert: Amanda
am 1 Dez. 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 Kommentare
Benjamin Thompson
am 1 Dez. 2022
Is this a GUIDE GUI or AppDesigner GUI? You may want to attach your current work for the Community to reference.
Akzeptierte Antwort
Kevin Holly
am 1 Dez. 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)';
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!