辅导COMP 208、讲解Engineering留学生、Matlab编程辅导、辅导Matlab

- 首页 >> Matlab编程


COMP 208: Computers in Engineering

Fall, 2018

Assignment 5

The Mouse Chase

Integrity

These assignments are to be done individually. You can collaborate on

understanding the problem but you must write the solution individually.

Your submission might be subject to Plagiarism detection software.

Due Date

Assignment 5 is due on November 20, 2018 at exactly 11:59. The cutoff is

automated and is exactly at this time. Assignments submitted within the

next hour will be considered late. After that time they will not be accepted

at all.

Introduction

This assignment deals with a problem known as the mouse or beetle

problem. A description can be found on the web site:

http://mathworld.wolfram.com/MiceProblem.html

In the general problem, n mice start at the corners of a regular n-gon. Each

mouse travels towards its closest neighbor (in a counterclockwise direction)

at a constant speed. The paths that the mice take form spiral curves. An

animation of the pattern can be seen on the above web site. The patterns

formed for n=3, 4, 5 and 6 look like the following:

Assignment

In this assignment, you are to generate a numerical solution that determines

the path of the mice.

Write a Matlab function definition that, given the value n, returns two

vectors of length n representing the x and y coordinates of the n-gon that

you start with.

Write a Matlab script that inputs a value n and generates the coordinates of

each of the n mice as they move towards each other. You will then graph the

paths the mice take.

Methodology

Start by initializing the positions of the n mice. The positions should be

symmetric and they should all lie on the unit circle centered at the origin.

You could use two vectors of length n to represent the x- and y- coordinates

of each of the mice.

On each iteration

Each mouse should move a distance d towards its neighboring mouse.

That is, towards the closest mouse in a counterclockwise direction.

(Hint: To find the coordinates of neighbor of mouse x, you just have to

add 1 to x modulo n. You can use the Matlab ‘mod’ function)

Generate the new coordinates of each mouse.

In order the graph the function, you could store the sequence of vectors in

matrices, with each line representing the coordinates at one of the time

steps.

The iterations should be repeated until the mice are sufficiently close to each

other.

You can use a value of 0.01 for d, the distance each mouse moves at each

time step.

Test you program for at least 5 different values of n.

Requirements

Your code must meet these requirements:

The script must be written in Matlab

Use sensible variable names.

Comment and indent your code

Submit a text file with the scripts and function definitions you created.

Also submit the graphs you produced. Name your files A5_123456789

and Graphs_123456789 where 123456789 is your ID. The Graph file

should have images of all the graphs generated for the different values

of n.

If any of the above requirements is not respected you might lose marks.



站长地图