This is what I have so far:
function f = randnum_reject(a,b,c)
randnum_reject = (b-a)*rand + a; f = randnum_reject; if f == c f = (b-a)*rand + a; else f = randnum_reject; end end
I know I probably made the mistake right after I assigned the output to f. I just really don't have any ideas as to how exclude c when I call random numbers from a to b
No products are associated with this question.
You don't need a for-loop for this problem.
p = [a:c-1,c+1:b]; f = p(ceil((b-a)*rand));
Play games and win prizes!Learn more