function b = rchoose(a,e)
% Randomly select one or numbers from a set of numbers
% Syntax b = rchoose(a,n)
% b has the same structure as a.
% If second argument is entered then
% n values are randomly selected from the set.

switch nargin
case  1
    c = size(a);
    d = a(randperm(length(a(:))));
    b = reshape(d,c);
case  2
    c = size(a);
    d = a(randperm(length(a(:))));
    b = d(1:e);
otherwise
    disp('Only 1 or 2 arguments allowed')
end
