Date: Jul 14, 2013 4:09 AM
Author: Bruno Luong
Subject: Re: generate specific random value except some numbers

A = [1:40];
B = [10 13 22 27];

left=[A(1) B+1];
right=[B-1 A(end)];
n = right-left+1;
e = [0 cumsum(n)];
a = floor(e(end)*rand(1,1e5));
[~, d] = histc(a, e);
r = a+d+A(1)-1;

% Bruno