MATLAB: Creating random points in a circle

circlegridtemperature

I am new to MatLab but I am trying to write code for a problem and a couple of things are sticking me up. I am trying to create X number of random points within a circle. The purpose being to model a camp fire and map temperature from the center of the circle at the hottest to the outside. And I am lost. And I can't find an example anywhere I might be able to pull apart and work with. And help would be very much appreciated.
Thanks!

Best Answer

Let the circle be of radius R and center at (x0,y0). Let n be the desired number of points within.
t = 2*pi*rand(n,1);
r = R*sqrt(rand(n,1));
x = x0 + r.*cos(t);
y = y0 + r.*sin(t);
plot(x,y)
Related Question