Wednesday, July 15, 2009

Square wave plot

% generation of square wave
%****************************************
y=0:.001:2;
for j=0:2:12;
x=y;
plot(j,x,'r');
hold on;
end

for k=0:4:12;
x=k+y;
m=2;
plot(x,m,'r')
hold on
end

for k=2:4:12;
x=k+y;
m=0;
plot(x,m,'r');
hold on;
end
hold off

axis([0 12 -0.5 2.5])

No comments: