Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using MATLAB Homework 7-Iteration Homework 7-Iteration Function Name: XMarksTheSpot map Inputs: 1. 2. (char) An NxM character array representing a map (char)A 1xN character vector

image text in transcribedUsing MATLAB

Homework 7-Iteration Homework 7-Iteration Function Name: XMarksTheSpot map Inputs: 1. 2. (char) An NxM character array representing a map (char)A 1xN character vector representing a series of directions MAUQEH otqlDao aLbls Outputs: 1. (cha) A string representing the result and the path you take directions'ESSWSESEEE treasure XMarks TheSpot (nap, directions) treasureI fournd the treasure by following the path along MAtLaBX! Background: Yau and your friends stumble upon an ancient treasure map one day and decide to embark on an adventure. Even though you tell them you'll meet up tomorrow to look for it together, you grow suspicious that they are trying to claim the treasure for themselves! As a CS 1371 student, you decide to use your MATLAB skils to try to find it before your friends do! Notes: The instructions will never guide you out of the bounds of the map andNSEand Ware the only directions ino diagonals). . Function Description: Write a function that navigates through a character array map based on given directions. . If you enccunter the'X in your path, ycu shculd stop there because there's no point in Starting at the top left corner, move according to the following directions travelling further Letters can repeat and the path can intersect with itself There is no guarantee that there is a treasure in the map . There may be mutiple treasures, but always stop at the first one Only capital' curnts as a treasre, not'x' owercase) Up Down Right Left S' After each direction, make sure to record your current location (the value of the character in the map). Keep going through the directions until you reach the treasure, represented by an 'x' or reach the end of the directions If you encounter the 'x', your final output should be in the fom: I found the treasure by following the path along ! If you go through all the given directions and don't find the treasure, output: I nt along the path ! If you go through all the given directions and don't find the treasure, output: I nt along the path

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions