Sie verfolgen jetzt diese Frage
- Aktualisierungen können Sie in Ihrem Feed verfolgter Inhalte sehen.
- Je nach Ihren Kommunikationseinstellungen können Sie auch E-Mails erhalten.
how can I plot a game board in a figure
Akzeptierte Antwort
30 Kommentare
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
- if there is no "traditional" figure at all, that code would cause one to be created
- if there are traditional figures, but none of them are marked internally as the "current figure", then that line of code would result in a new traditional figure being opened. Usually it is not enough to delete the current figure in order to cause the "current figure" to be set empty: in such a case, the current figure is usually selected from the children of the graphics root. However, figures would not be eligible for automatic selection if the figure handlevisibility property is set "off" or (sometimes) "callback". Also, if the graphics root CurrentFigure property is deliberately set to empty, then no other figure will be substituted when a figure is closed.
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
- 0 -- not occupied by either player and neither player has fired at the other player there
- 1 -- occupied by the player only and neither player has fired at the other player there
- 2 -- occupied by the opponent only and neither player as fired at the other player there
- 3 -- occupied by the player and the opponent and neither player has fired at the other player there
- 4 -- not occupied by either player and the player has fired at the opponent there -- a miss for the player
- 5 -- occupied by the player only and the player has fired at the opponent there -- a miss for the player
- 6 - occupied by the opponent only and the player has fired at the opponent there -- a hit for the player
- 7 occupied by the player and the opponent and the player has fired at the opponent there -- a hit for the player
- 8 not occupied by either player, and the opponent has fired at the player here -- a miss for the opponent
- 9 occupied by the player only and the opponent has fired at the player here -- a hit for the opponent
- 10 occupied by the opponent only and the opponent has fired at the player here -- a miss for the opponent
- 11 occupied by the player and the opponent and the opponent has fired at the player here -- a hit for the opponent
- 12 not occupied by either player and the player has fired at the opponent here and the opponent has fired at the player here -- a miss for the player and a miss for the opponent
- 13 occupied by the player only and the player has fired at the opponent there and the opponent has fired at the player there -- a miss for the player but a hit for the opponent
- 14 occupied by the opponent only and the player has fired at the opponent there and the opponent has fired by the player there -- a hit for the player and a miss for the opponent
- 15 occupied by the player and the opponent and both have fired at each other there -- a hit for the player and a hit for the opponent
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
- pcolor() is the wrong thing to use. Use image() instead -- but make sure the data values are uint8() so that the data values can act like images into the color map (I already showed you an example of a color map)
- input() with only a prompt always executes the line that the user types as if it were code. So if you ask the user to enter h or v and they enter those, then MATLAB would attempt to execute the v or p, by searching for variables and functions with those names. If you want the user to enter text then add the 's' option to input()
- Use strcmp() to compare text. For example strcmp(orientation, 'v')
- You will find that it is easier to have the user enter positions in terms of grid coordinates. In classic Battleships game the rows are numbered 1 to 10 and the columns are labeled 'A' to 'J' . If you have the user enter the coordinates as text you could figure out whether they had entered number-letter or letter-number and extract appropriate parts.
- The reason it is easier with grid coordinates than with numbers like 1 to 36, besides being easier for the user to understand, is that when you want to place a ship, it is easiest to have row and column of the starting point so that you can use (row, column:column+length-1) or (row:row+length-1,column) like I showed in https://www.mathworks.com/matlabcentral/answers/1614260-how-can-i-plot-a-game-board-in-a-figure#comment_1899030
-
Verknüpfen
Direkter Link zu diesem Kommentar
-
Verknüpfen
Direkter Link zu diesem Kommentar
Weitere Antworten (0)
Siehe auch
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Es ist ein Fehler aufgetreten
Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asien-Pazifik
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)