Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Does anyone helpe me to explain wht is this meant by each step? Thanks function value = random_pi() %creates 10,0000 points N = 100000; %

Does anyone helpe me to explain wht is this meant by each step? Thanks

function value = random_pi()

%creates 10,0000 points N = 100000; % Numbers of input point X = -1+2*rand(1,N);% X vector of N values Y = -1+2*rand(1,N); % Y vector of N values j =1; hold on; viscircles([0,0],1); z=3; %size

for i=1:N if (Y(i)^2+ X(i)^2)<1 % check point whether falls inside the circle. x(j) = X(i);% This vector contains x points which falls in circle y(j) = Y(i);% This vector contains y points which falls in circle j = j+1; %scatter(X(i),Y(i),z,'filled');

end end

scatter(x,y,z,'filled'); hold off; pi_value = (j*4)/N; % calculate value of pi disp(pi_value); value = [x,y]; end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

Students also viewed these Databases questions