To build the board, the following steps are to be followed:Build an empty 8 x 8 board filled with zeros using zeros command. Consider 0 to represent no boat while 1 to represent the presence of a boat.
To place the rowboats, use a for loop to control and perform iterations for randomly placing 6 rowboats on the board. Using the random number generator randi to randomly pick a space on the board. To place each Rowboat on the board, you have to check whether the chosen space is empty or not using a logical test like GB(m,n) == 0. After checking the chosen space, if it's empty and needs to place more rowboats, then change the value of that space to 1, i.e., GB(m,n) = 1. Keep track of how many rowboats are placed on the board. Create an image of the board using the instructions below:Use imagesc(GB) to display the image of the board. The GB is the name of the array. Use the command 'axis square' to correct the shape of the image. Use the command 'title('My Row Boat Placement")' to add the title to the image. Put your name on the label for the x-axis. Use the xlabel command as with plots. Avoid putting a label on the y-axis. Use the command "grid on" to draw thin lines showing your Row Boat placement. Use xticks (1:1:8) and yticks (1:1:8) commands to add tick marks and make your board image a bit prettier.The for building the board and placing rowboats is given below:```matlabGB=zeros(8,8); % build the empty boardcount=0;for i=1:10000 % use a very large number of iterationsm=randi(8); % randomly pick row numbern=randi(8); % randomly pick column numberif GB(m,n)==0 % check if space is emptycount=count+1; % update the countGB(m,n)=1; % place the rowboatif count==6 % check if all rowboats are placedbreak;endendendimagesc(GB)axis squaretitle('My Row Boat Placement')xlabel('Name')grid onxticks (1:1:8)yticks (1:1:8)```
To know more about code snippet visit:
https://brainly.com/question/30471072
#SPJ11