Step 1: Build the Board 1. Build an empty 8 x 8 board (call the Game Board array GB ) filled with zeros. (You must use the zeros command for this). 2. For your board we will assume that a value of 0 in that space means no boat there and a 1 means a boat is hidden there. 3. Use a FOR loop to control placing your Rowboats on the board. THINK ABOUT IT before you start writing code. It may take more than 6 attempts to place your 6 Rowboats because some spaces may be randomly picked more than once. So, you need a FOR loop with a very large number of iterations such as 10000 to ensure that you have a good chance to find 6 empty spaces for the Rowboats. 4. To place each Rowboat on the board: Each row number, m, and each column number, n, is a separate random number. You are to use the random number generator randi to randomly pick a space on the board like this: m = randi(8) and n = randi(8) o Check if the space (m,n) is empty using a logical test like: GB(m,n)==0. You also need to test if you still need to place more Rowboats on the board. o If both tests are true, then change the value of that space to 1 to show that you have placed a Rowboat there. That is, GB(m,n) = 1. You may also need to keep track of how many Rowboats you have put on the board. 5. After you have placed the 6 Rowboats on your board, use the instructions below to create an image of the board showing where the 6 Rowboats are positioned. • To show the board as an image, use these three commands: imagesc(GB) % GB is the name of your array axis square' % This makes your image a square shape and corrects for screen resolution title('My Row Boat Placement") % The title I want you to use for this problem. Put your name on the label for the x-axis. (Use the xlabel command as with plots.) o DO NOT put a label on the y-axis. Add another new command called "grid on" to draw thin lines showing your Row Boat placement. Add the following 2 lines of code to add tick marks and make your board image a bit prettier: xticks (1:1:8) yticks (1:1:8) You should see 6 Rowboats on your board. Next week we begin to talk more about images, but we wanted to introduce how to make an image, like the board, in preparation for that.

Answers

Answer 1

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


Related Questions

Other Questions
a child on a merry-go-round takes 4.4 s to go around once. what is his angular displacement during a 1.0 s time interval? using the factor theorem, which polynomial function has the zeros 4 and 4 5i? x3 4x2 23x 36 x3 12x2 73x 164 x2 8x 5ix 20i 16 x2 5ix 20i 16 Peyton Manufacturing is trying to decide between two different conveyor belt systems. System A costs $280,000, has a four-year life, and requires $85,000 in pretax annual operating costs. System B costs $396,000, has a six-year life, and requires $79,000 in pretax annual operating costs. Both systems are to be depreciated straight-line to zero over their lives and will have zero salvage value. Suppose the company always needs a conveyor belt system; when one wears out, it must be replaced. Assume the tax rate is 25 percent and the discount rate is 9 percent. Calculate the EAC for both conveyor belt systems. (Your answers should be negative values and indicated by minus signs. Do not round intermediate calculations and round your answers to 2 decimal places, e.g., 32.16.) When drawing a standard demand curve on a graph a. Price is on the vertical axis while time is on the horizontal axis b. Price is on the vertical axis while quantity is on the horizontal axis c. Quantity is on the vertical axis while price is on the horizontal axis d. Quantity goes up as you approach the origin e. The closer to zero, the higher the price The worlds poorest countries cannot find anything to export. There is no resource that is abundant certainly not capital or land, and in small poor nations not even labor is abundant A 0.200-kg object is attached to a spring that has a force constant of 95.0 N/m. The object is pulled 7.00 cm to the right of equilibrium and released from rest to slide on a horizontal, frictionless table. Calculate the maximum speed Umas of the object. Upis m/y Find the location x of the object relative to equilibrium when it has one-third of the maximum speed, is moving to the right, and is speeding up. m answer all of fhem pleaseMr. Potatohead Mr. Potatohead is attempting to cross a river flowing at 10m/s from a point 40m away from a treacherous waterfall. If he starts swimming across at a speed of 1.2m/s and at an angle = 40 whichcomposers invented the twelve-tone system of composition Suppose that X ~ N(-4,1), Y ~ Exp(10), and Z~ Poisson (2) are independent. Compute B[ex-2Y+Z]. what is the best definition of relativistic thought according to perry it may be the direction things are headed anyway, he says. "I don't think it's just manage- ment practices that are getting soft."Questions 1. What are some of the potential advantages of providing employees with 2. 3. relatively positive performance appraisals and feedback? What are some of the potential disadvantages of providing employees with positive performance appraisals and feedback?What are some of potential advantages of providing employees with negative feedback? What are some of the potential disadvantages of providing employees with negative feedback? Source: Rachel Feintzelg. "You're Awesome! Firms Scrap Negative Feedback, The Wall Street Journal, February 11, 2015, B1, B5, 4. n simple linear regression, r 2 is the _____.a.coefficient of determinationb.coefficient of correlationc.estimated regression equationd.sum of the squared residuals Explain why the pursuit of abalanced-budget (or deficit target) duringa recession may worsen therecession? which of the following statements about miscible liquids is correct? i. the components form a homogeneous solution. ii. the partial pressure of each component is the vapor pressure of the mixture times the components mole fraction. iii. each component has its own vapor pressure. Freda's Florist reported the following before-tax income statement items for the year ended December 31, 2021: Operating income $ 263,000 Income on discontinued operations 58,000 All income statement items are subject to a 25% income tax rate. In its 2021 income statement, Freda's separately stated income tax expense and total income tax expense would be: Publishing a policy and standards library depends on the communications tools available within an organization. Some organizations keep documents in Word format and publish them in PDF format. Other organizations use Governance, Risk, and Compliance (GRC), a class of software for supporting policy management and publication. In addition to authoring documents, GRC software typically includes a comprehensive set of features and functionality, such as assessing the proper technical and nontechnical operation of controls, and mitigating/remediating areas where controls are lacking or not operating properly (governance). Answer the following question(s): Why might an organization use the Word and PDF approach rather than GRC software, and vice versa? If the following times are estimated for an activity of the project, calculate the mean and the variance using PERT analysis.a = 5b = 13m = 9 what is the mole ratio of ammonia (with a pkb of 4.75) to ammonium chloride in a buffer with a ph of 9.03 ? Find the missing value required to create a probabilitydistribution. Round to the nearest hundredth.x / P(x)0 / 0.181 / 0.112 / 0.133 / 4 / 0.12 when your hand touches a hot stove, you immediately and reflexively pull it away. This action was controlled by your _____A)CNSB)spinal cordC)brainD)reflexes