I currently have the following function, but is there a more efficient way to generate a random integer within a range and exclude a specific integer in Matlab?
function aNew = random(a)
aMin = a-100;
aMax = a+100;
aNew = a;
while aNew == a
aNew = randi([aMin, aMax]);
end
You can use the function
randsampleto draw samples from a specified distribution.Something like this should work fine
Update
If you wanted to exclude multiple values from your population you could use the
setdifffunction.