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

use Matlab  use Matlab 5. Write a program to perform the following task:

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!