MATLAB: How to create an random points in desired circle using rand function?

humble requestresource allocation using matlab

i want to create an one circle and in that i want to create random points and circle around that point at my desired radius,to shoe resource allocation in mobile using matlab

Best Answer

You need to generate points which have random angles smaller or equal to 2*pi and random radius smaller or equal to the circle radius, here is the code:
n=100; % number of points that you want
center = [1 ,2]; % center coordinates of the circle [x0,y0]
radius = 10; % radius of the circle
angle = 2*pi*rand(n,1);
r = radius*sqrt(rand(n,1));
X = r.*cos(angle)+ center(1);
Y = r.*sin(angle)+ center(2);
plot(X,Y,'.k')