Topics: Plotting in MATLAB Program Specification: The owner of a small private l
ID: 3760559 • Letter: T
Question
Topics: Plotting in MATLAB Program Specification: The owner of a small private lake has commissioned you to write a program to keep their eight boats safe while on the lake. You must keep track of each boats position (x-cord, y-cord), and alert each boat if it gets to close to another boat or the shoreline Write a program that opens a plotting grid window (labeled Lake Matlab) with its axis set to [-12 12-12 12] and the plots of the four lines: x =-11; x = 1 1; y =-11; y = 1 1 with a black-point style line. So the lake has a 20unit X 20unit area in which the boats can move about. Generate randomly (and save) the coordinates of eight boats on this lake. Repeatedly do the following 40 times: 1. Move each boat on the lake by randomly modifying either it x-coord or its y-coord by +-1, provided that this does not put the boat on the shore - if it would then that bout does not move this time 2. Re-plot the lake so that the boats are also viable (as diamond points) with the following color requirements: a) A boat whose distance is more than the square root of two from all other boats and whose distance is more than one from all lake boundary lines is Greern b) A boat whose distance is more than the square root of two from all other boats but whose distance is exactly one from any lake boundary lines is Magenta c) A boat whose distance is exactly the square root of two or one from any other boat is Yellow d) A boat whose distance is exactly zero from any other boat is Red (collision) 3. Delay for 0.5 seconds Outline: 1. Create a MATLAB Script m file 1. Write the necessary MATLAB commands to meet the game specification given above Make sure to test your “program" when it is done 1. You really need to run your program a number of time to do this thoroughlyExplanation / Answer
the grid size is 20*20 and 8 boats are randomly placed let the velocity of the boats are 1unit/min then the boats which are opposite on the same line will meet at 10 units i-e's (0,0). at that instant the boat should get an response.
plot{r(,:1),r(:,2),};
axis equals
xlabels{($*$ [m]' ) ylabels('$*$ [m]');
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.