Siemens star in MATLAB
Code:
clc
clear
all
close
all
k=input('Enter the no. of tracks you want to make:');
t=0:2*pi/(k*2):2*pi;
fill([-1
-1 1 1],[-1 1 1 -1],'k');
axis
square;
hold
on;
pause(10);
x=cos(t);
y=sin(t);
temp=0;
gemp=1;
hemp=1;
for i=1:length(t)-1
if(rem(temp,2)==0)
patch([x(gemp) 0 x(gemp+1)
x(gemp)],[y(hemp) 0 y(hemp+1) y(hemp)],'w');
else
patch([x(gemp) 0 x(gemp+1)
x(gemp)],[y(hemp) 0 y(hemp+1) y(hemp)],'k');
end
hold on;
pause(0.5);
gemp=gemp+1;
hemp=hemp+1;
temp=temp+1;
axis([-1 1 -1 1]);
axis square;
end
No comments