Question
matlab code, how do I move south, west, north from the here location?
Neighbors 7 40 Here South North West East 35 30 25 20 3 5 2 6 2 3 You are not writing any of the plotting code it is already
index of the location you an indicatin 71 xxneigt neighbors ou should return. 8 XOUTPU 91 %xx-th n locations of the neighbors
0 0
Add a comment Improve this question Transcribed image text
Answer #1

function [x,y] = findNeighbors(map,row,col,direction)
   if(direction == "east") % if direction is east
       x = [col+1, col+1, col+1];
       y = [row-1, row, row+1];
   elseif (direction == "west") % if direction is west
       x = [col-1, col-1, col-1];
       y = [row-1, row, row+1];
   elseif (direction == "north") % if direction is north
       x = [col-1, col, col+1];
       y = [row+1, row+1, row+1];
   else % if direction is south
       x = [col-1, col, col+1];
       y = [row-1, row-1, row-1];
   end  
end

Add a comment
Know the answer?
Add Answer to:
matlab code, how do I move south, west, north from the here location? Neighbors 7 40...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need the algorithm and the c++ program North West Down Suppose two divers start at...

    I need the algorithm and the c++ program North West Down Suppose two divers start at the surface and establish the following coordinate system: x is to the West, y is to the North, and z is down. Diver 1 swims 55 ft. West, 36 ft. North, and then dives 25 ft. Diver 2 dives 15 ft., then swims East 20 ft. and then North 59 ft. a. Find the distance between diver 1 and the starting point. b. How...

  • #2 You are going to add more code to carClass.cpp. 0. Make sure you finished the...

    #2 You are going to add more code to carClass.cpp. 0. Make sure you finished the lab part: goForward, turnRight(), getDirection(), getXO, getY() and get Modelo 1. Preparation: In the last lab, we tested our functions using cl. Comment out that section. Create c2 with any make and model. int main() Car cl("Toyota", "Camry") 77777777777777 lereate c2 here Tested the functions in the last lab cout <<cl.getModel() << endl; Comment out this section cout <<cl.getX() <<"*«<cl.getY() << endl; return 0;...

  • Make sure to include: Ship.java, ShipTester.java, Location.java, LocationTester.java, Grid.java, GridTester.java, Player.java, PlayerTester.java, battleship.java. please do every...

    Make sure to include: Ship.java, ShipTester.java, Location.java, LocationTester.java, Grid.java, GridTester.java, Player.java, PlayerTester.java, battleship.java. please do every part, and include java doc and comments Create a battleship program. Include Javadoc and comments. Grade 12 level coding style using java only. You will need to create a Ship class, Location class, Grid Class, Add a ship to the Grid, Create the Player class, the Battleship class, Add at least one extension. Make sure to include the testers. Starting code/ sample/methods will be...

  • I just need a help in replacing player 2 and to make it unbeatable here is my code: #include<i...

    I just need a help in replacing player 2 and to make it unbeatable here is my code: #include<iostream> using namespace std; const int ROWS=3; const int COLS=3; void fillBoard(char [][3]); void showBoard(char [][3]); void getChoice(char [][3],bool); bool gameOver(char [][3]); int main() { char board[ROWS][COLS]; bool playerToggle=false; fillBoard(board); showBoard(board); while(!gameOver(board)) { getChoice(board,playerToggle); showBoard(board); playerToggle=!playerToggle; } return 1; } void fillBoard(char board[][3]) { for(int i=0;i<ROWS;i++) for(int j=0;j<COLS;j++) board[i][j]='*'; } void showBoard(char board[][3]) { cout<<" 1 2 3"<<endl; for(int i=0;i<ROWS;i++) { cout<<(i+1)<<"...

  • how would i do this code in MATLAB Step 2: Coding You are given a vector...

    how would i do this code in MATLAB Step 2: Coding You are given a vector t. We define x = di cos(it) 16 Yi = 1:1.sin(i-1) for i = 1,2,...,15,16 where multiplication of vectors is assumed to be point-wise. Create a 4x4 subplot. - In the ith location, plot the values of x; versus y; with a solid line (pick a color). - Make the axis tight Run the code a few times before submitting. Note that the size...

  • Please round all entries below to the nearest ten-thousandth, i.e. nearest 4th decimal place, where necessary. You are salling your boat far off the west coast of some continent. There are three r...

    Please round all entries below to the nearest ten-thousandth, i.e. nearest 4th decimal place, where necessary. You are salling your boat far off the west coast of some continent. There are three radio stations on the coast, call them stations A, B, and C, which conveniently all lie on a signle line! Your map tells you that station A is 500 miles north of station B, and station B is 1500 miles north of station C. Let's say that station...

  • This is the code we have to edit, i know how to do everything except finding...

    This is the code we have to edit, i know how to do everything except finding if the x and y are in the space, please explain to me when you do the code. We are using addshape() api and more. public class Skeleton { public static void main(String[] args) { //================================ //== Setting up game window ====== SpaceGame myGame; //declaring the object form the class Scanner scan = new Scanner(System.in); System.out.println("What is the window name? "); //window title text...

  • Matlab code assistance - task 1 and 6 I think I am right and just need...

    Matlab code assistance - task 1 and 6 I think I am right and just need to be pointed in the right direction if I should change anything %% Task 1 % create the 3 row vectors shown in Ex 8 using 3 different approaches Ex 8 = using the colon operator and also the linspace function, create the following row vectors -5 -4 -3 -2 -1 5 7 9 8 6 4 % 1. list the values explicitly (square...

  • The Problem A robot is asked to navigate a maze. It is placed at a certain...

    The Problem A robot is asked to navigate a maze. It is placed at a certain position (the starting position) in the maze and is asked to try to reach another position (the goal position). Positions in the maze will either be open or blocked with an obstacle. Positions are identified by (x,y) coordinates. At any given moment, the robot can only move 1 step in one of 4 directions. Valid moves are: ● Go North: (x,y) -> (x,y-1) ●...

  • MATLAB only please I am trying to get my getdatafuntion to work. I am also trying to get all my x...

    MATLAB only please I am trying to get my getdatafuntion to work. I am also trying to get all my x's, y's, and v's to popup in the command window so I can put in any value and it will find the value for me using the equation I put in. function project_9_sjl() % PROJECT_9_SJL project_9_sjl() is the driver function for the program. % %    Name: Scott Lawrence %   Date: 3/27/2019 %   Class: CMPSC 200 %   Description: Determine the optimal...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT