particle distributed on a ring
Show older comments
I want to generate a ring distribution of particles. This is my code so far
function [x,y]=cirrdnPJ(x1,y1,rc)
%the function, must be on a folder in matlab path
a=2*pi*rand;
r=sqrt(rand);
x=(rc*r)*cos(a)+x1;
y=(rc*r)*sin(a)+y1;
end
%to test the function
clf
axis equal
hold on
x1=1;
y1=1;
rc=1;
[x,y,~] = cylinder(rc,200);
plot(x(1,:)+x1,y(1,:)+y1,'r');
x1=1;
y1=1;
rc2=2;
[x,y,~] = cylinder(rc2,200);
plot(x(1,:)+x1,y(1,:)+y1,'p');
for t=1:1000 %loop until doing 1000 points inside the circle
[x ,y]=cirrdnPJ(x1,y1,rc2-rc);
plot(x,y,'x')
pause(0.01) %if you want to see the point being drawn
end
however the marks are appearing inside inner circle and not between two circles as I want. Any help or suggestion would be appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Uniform Distribution (Continuous) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!