rect.m
function output = rect(x)
%this function is a rectangle%output=0;
len=length(x);
for i=1:len
disp(x(i));
if x(i)<0 || x(i)>5
output(i)=0;
else
output(i)=3;
end
end
draw_rect.m
% this script draw a rect
hx=-5:0.01:10;
y=rect(hx);
figure(1);
plot(hx,y,'g-');
axis on;
axis([-6 11 -1 6]);