
clear;

%  Fill a vector A with 100 random numbers. 
%  The function rand returns random numbers in the range from 0 to 1.

A = rand(1,100);

%  Use a for loop to scale the numbers in A so that they fall 
%  into the interval from -10 to 10, and store them in B.

for i=1:100
    B(i) = -10 + 20*A(i);
end

%  Use another for loop to sort the numbers into 3 vectors. 
%  All numbers in B that are below -3 go into C1, 
%  all numbers between -1 and 1 got into C2, 
%  and all numbers above 5 go into C3.

n1=0;  n2=0;  n3=0;
for i=1:100
    if B(i) < -3
        n1=n1+1;
        C1(n1)=B(i);
    elseif (B(i) >= -1) && (B(i) <=1)
        n2=n2+1;
        C2(n2)=B(i);
    elseif B(i) > 5
        n3=n3+1;
        C3(n3)=B(i);
    end
end

%  Print out how many numbers are in each of C1, C2, and C3.

fprintf('  N1=%d  N2=%d  N3=%d \n',n1,n2,n3);
