# Math Help - Matlab - Fuctions/Scripts

1. ## Matlab - Fuctions/Scripts

So basically I have to edit this code so that I can find the probability of the points falling within a circle of
radius 0.5 centered at (0.5, 0.5). I then need to run it for 1000 points!!!I'm really new to matlab and can't figure it out.

Code:
N = 100;
figure(1);
clf;
point = rand([2 N]);
plot(point(1,:), point(2,:), 'xb');
xlim([0 1]);
ylim([0 1]);

hold on;
count = 0;
for i=1:N
if (point(1, i) < 0.5) && (point(2,i) < 0.5)
plot(point(1,i), point(2,i), 'xr')
count = count + 1;
end
end

probability = count / N;
title(strcat('Probability is:', num2str(probability)));

2. Originally Posted by exzacklyright
So basically I have to edit this code so that I can find the probability of the points falling within a circle of
radius 0.5 centered at (0.5, 0.5). I then need to run it for 1000 points!!!I'm really new to matlab and can't figure it out.
Little change is necessary. Do you understand what your code already does? (You should try to run it)
A question you should consider is: given two coordinates $x,y$, how can you check (by a formula) whether the point $(x,y)$ is in the circle you describe?