Question

Can someone help me to solve it by Matlab?

Use the Boffons Needle experiment to approximate pi on the following scenario. A dart is thrown at a square with sidelength

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

clc
clear all
close all
n=[4:8];
n=10.^n;
for i=1:length(n)
fprintf('For n=%d\n',n(i));
throws = n(i); % percent makes the rest of the line a comment
x=rand(1,throws)*2; % a vector of 10000 pseudorandom numbers
% in the range [0,2)
theta=rand(1,throws); % semicolon supresses printing
theta=0.5*pi*theta; % theta now 10000 random numbers between 0 and pi/2
hits= x<=sin(theta); % hits is a vector of 0's where false
% and 1's where true
sum(hits); % no semicolon prints the number of hits out of the 10000 throws
piEst=throws/sum(hits)
end

MATLAB R2014a EDITOR Find Files Compare ▼ Comment Print New Open Save Breakpoints Run Run and Advance Advance Run and Indent

Add a comment
Know the answer?
Add Answer to:
Can someone help me to solve it by Matlab? Use the Boffon's Needle experiment to approximate...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can someone help me to solve it by Matlab? 17. Write a script which does the...

    Can someone help me to solve it by Matlab? 17. Write a script which does the following: S- Σ IMPORTANT! Make sure the summation runs BACKWARDS-that is, starts with k-N, and quits with k-1. After S is computed, multiply it by 6, take the square of the result, and report the answer. Run this for N 10, 100, 1000, and 10000. Hmmmmm....

  • Can someone help me to solve it by Matlab? ) Many dice games use two 6-sided...

    Can someone help me to solve it by Matlab? ) Many dice games use two 6-sided dice, where each side faces up with equal probability, each turn consists of rolling both dice, and where the SUM of the two dice values is the outcome used in the game. Figure out how to simulate 3600 such die rolls, and then to make a nicely designed histogram displaying the outcomes as a PERCENT of the total rolls

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT