Skip to content

Commit

Permalink
matlab scripts for generating random clusters of components
Browse files Browse the repository at this point in the history
  • Loading branch information
keznikl authored and andranikm committed Feb 7, 2014
1 parent 04f1571 commit bdf900d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
28 changes: 28 additions & 0 deletions jdeeco-simulation-demo/matlab/gen_componentcfg.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
y = betarnd(2,4,100,1);
x = rand(100,1);
XY = [x y];

plot(XY(:,1),XY(:,2),'*');


%to test the function
clf
axis equal
hold on
x1=1
y1=1
rc=10
[x,y,z] = cylinder(rc,200);
plot(x(1,:)+x1,y(1,:)+y1,':k')


[x y]=points_in_circle(x1,y1,rc, 1000);
plot(x,y,'bx')

[x y]=points_in_circle(x1,y1,rc, 50);
plot(x,y,'or')


[x y]=points_in_circle(x1,y1,rc, 500);
plot(x,y,'*g')

17 changes: 17 additions & 0 deletions jdeeco-simulation-demo/matlab/points_in_circle.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function [x, y]=points_in_circle(x1,y1,rc, cnt)

function [tx, ty]=inner(x1,y1,rc)
a=2*pi*rand;
r=sqrt(rand);
tx=(rc*r)*cos(a)+x1;
ty=(rc*r)*sin(a)+y1;
end
x = zeros(cnt, 1);
y = zeros(cnt, 1);
for t=1:cnt %loop until doing cnt points inside the circle
[tx, ty]=inner(x1,y1,rc);
x(t) = tx;
y(t) = ty;
end;
end

0 comments on commit bdf900d

Please sign in to comment.