%
% Lecture 06 Example 02
%
% Purpose: Print & plot random numbers in different categories
%
% Xin-Zhong Liang, UMD, 2012/08/23
%
for i = 1:100
    r = rand;   % rand generates random numbers
    if (r > 0.8)
       disp([num2str(i),'---', num2str(r),': very high'])
       plot(i,r,'^r');
    elseif (r <= 0.8) & (r > 0.6)
       disp([num2str(i),'---', num2str(r),': high'])
       plot(i,r,'*m');
    elseif (r < 0.4) & (r >= 0.2)
       disp([num2str(i),'---', num2str(r),': low'])
       plot(i,r,'og');
    elseif (r < 0.2)
       disp([num2str(i),'---', num2str(r),': very low'])
       plot(i,r,'vb');
    else
       disp([num2str(i),'---', num2str(r),': med'])
       plot(i,r,'dk');
    end
    pause(2)
    if i==1
       %axis([0,100,0,1]);  % forces all plots to use the same axis scale
       hold on;            % holds all subsequent plots 
    elseif i == 100
       hold off;           % releases the plot at the last step
    end
end
        