Question: use Matlab 5. Write a program to perform the following task: Use Matlab to draw a circle of radius 1 centered at the origin and
5. Write a program to perform the following task: Use Matlab to draw a circle of radius 1 centered at the origin and inscribed in a square having vertices (1. 1), (-1,1) (-1,-1) and (1-1). The ratio of the area of the circle to the area of the square is pi : 4 or /4, Hence, if we were to throw darts at the square in a random fashion, the ratio of darts inside the circle to the number of darts thrown should be approximately equal to /4 Write a for loop that will plot 1000 randomly generated points inside the square. Use Matlab's rand command for this task. Each time a random point lands within the unit circle increment a counter hits. When the for loop terminates, use fprintf to output the ratio darts that land inside the circle to the number of darts thrown Calculate the relative error in approximating /4 with this ratio
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
