Answered step by step
Verified Expert Solution
Question
1 Approved Answer
couldyou please help in matlab coding Initialization Section The first section should do the following: Clear the workspace and command window and close any figure
couldyou please help in matlab coding Initialization Section
The first section should do the following:
Clear the workspace and command window and close any figure windows
Create a grid matrix of all zeros this is the matrix that your robot will occupy
Initialize the robot's coordinates to be near the center can be or of the grid matrix by
setting that element of the grid matrix to
Create a second matrix to represent the targets; initialize to all zeros as well
Using the input function, prompt the user for the number of targets should be between
and
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.
Application : Array Operations
Designed to test skills with: array creation and operations; commandline inputoutput
Randomly choose that number of elements of the target matrix and set them to This line will
accomplish that assuming that your target matrix is called target and that the number of
targets entered by the user is numtargets you may use whatever variable names you
like:
NOTE: this will not necessarily give unique target positions, so there is a chance that the
number of targets placed in the matrix will be less than the number entered by the user
this is okay
Display the robot's location using the provided showimage function.
Set the title of the figure window so that it indicates the robot's position. You can do this using
string concatenation with the operator
Movement Section
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
Application : Array Operations
Designed to test skills with: array creation and operations; commandline inputoutput
Reporting Section
The third section should do the following:
Print to the command window a message indicating how many targets were found and how many
moves were made
Print to the command window how many targets remain you can determine this by summing
the entire target matrix
Display the targets using showimage.
Submission Requirements
Submission location: Carmen
Required Files:
Script file with comments m
A pdf file with the command window output you can just copy and paste your command window into a
word document and save it as a pdf filel
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