How to use a edit box on a GUI
13 次查看(过去 30 天)
显示 更早的评论
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 个评论
Benjamin Thompson
2022-12-1
Is this a GUIDE GUI or AppDesigner GUI? You may want to attach your current work for the Community to reference.
采纳的回答
Kevin Holly
2022-12-1
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)';
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!