I am trying to create the game Battleship in MATLAB r2013. I want to change the color of a push button with a function (without clicking it) in order to understand when the PC hit my panel of ships. Does anyone have any idea how I can do this? I have tried with the command set(myOwnBattleship.Apanel.tableA3,'BackgroundColor','k')
where the Apanel
is the player's panel and tableA3
is the button which I want to change color.
Asked
Active
Viewed 755 times
0

David Cain
- 16,484
- 14
- 65
- 75
-
Are you sure that's the handle name of your button? Sounds more like a name for a table to me... So, what happens when you execute that line? – jerad Jan 16 '14 at 20:06
-
I am not sure,how can I find the name of my button my friend?when I am running the function,the PC hits the player's panel but the color doesn't change....Error in myOwnBattleship1>pcHits (line 1388) set(myOwnBattleship.Apanel.tableA22, 'BackgroundColor','r' ) – user3203862 Jan 16 '14 at 20:39
1 Answers
0
Use a tool like findjobj-gui to look at your object hierarchy. I am not sure if it also gives you the matlab handles, but at least you see how things are nested which would enable you to find the right control.

Diederick C. Niehorster
- 839
- 6
- 26