# ps1_soln - r = ( x.^2 + y.^2 ).^.5; % estimate pi for n...

This preview shows pages 1–8. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
EE 497B Problem Set 1 Solutions -8- Problem 8: % EE 498B Spring 2008 % Problem Set 1, Problem 8 R = 0.25; % radius of dart board N = 1e6; % maximum number of times to throw the dart theta = zeros(N,1); % vector for storing estimate % Generate x and y coordinates of dart impact locations x = rand([N,1]) - 0.5; % center board at origin y = rand([N,1]) - 0.5; % Distance from center of square-board to dart impact
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: r = ( x.^2 + y.^2 ).^.5; % estimate pi for n throws Ni = 0; for n = 1 : N if r(n) <= R Ni = Ni + 1; end theta(n) = 16 *( Ni / n); % Estimate pi end ; % plot estimate semilogx([2:N], theta(2:N), '-b' , [2,N], [pi,pi], '--r' ) title( 'Estimate of \pi' ) ylabel( '\theta: Estimate of \pi' ); xlabel( 'N: Number of Throws in Experiment' ) legend( 'estimate' , 'true value' );...
View Full Document

## This note was uploaded on 07/23/2008 for the course EE 497B taught by Professor Schiano during the Spring '08 term at Pennsylvania State University, University Park.

### Page1 / 8

ps1_soln - r = ( x.^2 + y.^2 ).^.5; % estimate pi for n...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online