Question: Use monte carlo method to find area of circle radius 5 inside 7×7 square.
So this is the code I've put together so far to determine how many points land inside or on the circle (hits). My output for hits is 0 but I can't for the life of me figure out why, to me everything seems fine but clearly isn't.
clear;N= 1000; % number of points generated
a = -7;b = 7;hits= 0;for k = 1:N x = a + (b-a).*rand(N,1); y = a + (b-a).*rand(N,1); % Count it if it is in/on the circle
radii = sqrt(x.^2+y.^2); if radii <=5; hits = hits + 1; endenddisp(hits)
Best Answer