particle distributed on a ring
显示 更早的评论
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.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Uniform Distribution (Continuous) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!