Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

Cluster (Size =7) in MATLAB

Code:

r=input('Enter the cell radius');
a=input('Enter the x coordinate of the initial base station');
b=input('Enter the y coordinate of the initial cell');
t=0:pi/3:2*pi;
x=a+r*cos(t);
y=b+r*sin(t);
plot(x,y,'r')
axis square
hold on
t=0:pi/3:2*pi;
x2=a+(r+(r/2));
y2=b+sqrt(3)*(r/2);
x3=x2+r*cos(t);
y3=y2+r*sin(t);
plot(x3,y3,'c')
axis square
hold on;
x2=a+(r+(r/2));
y2=b-sqrt(3)*(r/2);
x3=x2+r*cos(t);
y3=y2+r*sin(t);
plot(x3,y3,'b')
axis square
hold on;
x2=a;
y2=b-sqrt(3)*r;
x4=x2+r*cos(t);
y4=y2+r*sin(t);
plot(x4,y4,'y')
axis square
hold on;
x2=a;
y2=b+sqrt(3)*r;
x4=x2+r*cos(t);
y4=y2+r*sin(t);
plot(x4,y4,'k')
axis square
hold on;
t=0:pi/3:2*pi;
x2=a-(r+(r/2));
y2=b+sqrt(3)*(r/2);
x3=x2+r*cos(t);
y3=y2+r*sin(t);
plot(x3,y3,'g')
axis square
hold on;
x2=a-(r+(r/2));
y2=b-sqrt(3)*(r/2);
x3=x2+r*cos(t);
y3=y2+r*sin(t);
plot(x3,y3,'m')
axis square
hold on;

Command Window:


OUTPUT:


Animation based code:

r=input('Enter the cell radius'); a=input('Enter the x coordinate of the initial base station'); b=input('Enter the y coordinate of the initial cell'); pause(1); t=0:pi/3:2*pi; x=a+r*cos(t); y=b+r*sin(t); figure pause(1); plot(x,y,'r') axis square hold on pause(1); t=0:pi/3:2*pi; x2=a+(r+(r/2)); y2=b+sqrt(3)*(r/2); x3=x2+r*cos(t); y3=y2+r*sin(t); plot(x3,y3,'c') axis square hold on; pause(1); x2=a+(r+(r/2)); y2=b-sqrt(3)*(r/2); x3=x2+r*cos(t); y3=y2+r*sin(t); plot(x3,y3,'b') axis square hold on; pause(1); x2=a; y2=b-sqrt(3)*r; x4=x2+r*cos(t); y4=y2+r*sin(t); plot(x4,y4,'y') axis square pause(1); hold on; x2=a; y2=b+sqrt(3)*r; x4=x2+r*cos(t); y4=y2+r*sin(t); plot(x4,y4,'k') axis square hold on; pause(1); t=0:pi/3:2*pi; x2=a-(r+(r/2)); y2=b+sqrt(3)*(r/2); x3=x2+r*cos(t); y3=y2+r*sin(t); plot(x3,y3,'g') axis square hold on; pause(1); x2=a-(r+(r/2)); y2=b-sqrt(3)*(r/2); x3=x2+r*cos(t); y3=y2+r*sin(t); plot(x3,y3,'m') axis square hold on; pause(1); t=0:pi/3:2*pi; x=a+r*cos(t); y=b+r*sin(t); fill(x,y,'r') axis square hold on pause(1); t=0:pi/3:2*pi; x2=a+(r+(r/2)); y2=b+sqrt(3)*(r/2); x3=x2+r*cos(t); y3=y2+r*sin(t); fill(x3,y3,'c') axis square hold on; pause(1); x2=a+(r+(r/2)); y2=b-sqrt(3)*(r/2); x3=x2+r*cos(t); y3=y2+r*sin(t); fill(x3,y3,'b') axis square hold on; pause(1); x2=a; y2=b-sqrt(3)*r; x4=x2+r*cos(t); y4=y2+r*sin(t); fill(x4,y4,'y') axis square pause(1); hold on; x2=a; y2=b+sqrt(3)*r; x4=x2+r*cos(t); y4=y2+r*sin(t); fill(x4,y4,'k') axis square hold on; pause(1); t=0:pi/3:2*pi; x2=a-(r+(r/2)); y2=b+sqrt(3)*(r/2); x3=x2+r*cos(t); y3=y2+r*sin(t); fill(x3,y3,'g') axis square hold on; pause(1); x2=a-(r+(r/2)); y2=b-sqrt(3)*(r/2); x3=x2+r*cos(t); y3=y2+r*sin(t); fill(x3,y3,'m') axis square hold on; pause(1);

Output:


No comments

Popular Posts

Followers