mercredi 28 octobre 2015

How to code for rabbit and tortoise race in matlab?

The racing track consists of a rectangle of perimeter P and area A. While the turtle runs slowly at the regular pace of one step per unit of time, the rabbit, who feels confident in his racing abilities, randomly decides to run for a random distance. When the rabbit runs, the distance it covers is an integer between 2 and 10 selected following the uniform distribution. Notes: A unit of time is represented by a loop iteration. The race starts in (0,0) at the bottom left corner of the rectangle, and is run in the clockwise direction.

Write a MATLAB function taking as input: P and A, as well as the probability for the rabbit to rest (that is, not to run). The function should plot the progress of the race at each unit of time using a red cross for the turtle and a blue line for the rabbit. Notes: The turtle and the rabbit both run on the same line. It is not necessary to plot the racing track. You are only required to plot the trajectory of the two runners.

Anyone can help me with this question!!?/




Aucun commentaire:

Enregistrer un commentaire