How do I use push buttons in a GUI as a condition in an if statement?

5 views (last 30 days)
Hi! I'm currently building Connect Four in Matlab for a class, and have built the entire code with the input as a menu statement. It isn't expected of us, but I would really like to use a GUI for the user to determine the column they wish to place their chip. My code with the menu input was based on a switch statement, so I changed it to an if and did something similar to what was described here with handles.column1=1; everything else=0. This isn't working at all for me. I have all the GUI code from the guide command up top, with my board just loaded normally (the buttons are on top of the columns, shown below),and the rest of my game code below. First thing it does: requires the user to click all buttons before starting the game, which just messes everything up from there. My main goal in this post is to correct this. Do I place the functions for the buttons elsewhere? I tried placing them within my game-play loop but got an error saying they were improperly nested.
If you can't tell, I'm a beginner and much of the resources I've been coming across have been a bit over my head. Any help will be greatly appreciated! Thanks!

Answers (0)

Categories

Find more on Just for fun in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!