Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The second section should do the following: Prompt the user for how far to move the robot in the columns and rows NOTE: Remember the
The second section should do the following:
Prompt the user for how far to move the robot in the columns and rows
NOTE: Remember the robot is actually located in a matrix, so the position is located
near the TOP left when graphed, not the BOTTOM left what we typically imagine as the
origin What we typically think of as movement in the direction is actually movement
between columns and movement in the direction is actually movement between rows
Update the robot's position
Update the grid matrix set the element for the previous position to and the new position to
Display the robot's position just as in the initialization section including title with correct robot
position location
Determine if there is a target at the robot's new coordinates. To accomplish this, perform an
elementwise multiplication of the grid matrix by the target matrix, and take the sum of all
elements. The result will be if there is not a target at the robot's location, or if there is
Set the element of the target matrix corresponding to the robot's position equal to That is
once a target is found, remove it from the target matrix.
Print to the command line using either disp or fprintf a message indicating whether a
target was found. Since we have not yet covered if statements, the easy way to do this is to select
one of two messages from an array using indexing. See the example message array in the script
template above.
Update the number of moves and number of targets found the former always increases by
while the latter increases by only if a target is found.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started