MATLAB: How can I produce zero mean pseudo random number which only takes -1 and 1 as amplitude

pseudorandomrandomrandom number generatorzeromean

Hi, There are multiple ways to get zero mean random number in MATLAB and Simulink. However, I need that these random numbers only take -1 and 1. For example, in discrete domain, where step size is ts, random generator mean must be zero at ts*(2^25) second. If you help me, I will be appreciated. Thanks. Derun Karabeyoglu

Best Answer

while true
a=randi([-1 1],10,1);%you can change 10 to an another positive integer value, it shows size.
if(mean(a)==0 && ~ismember(0,a))
break;
end
end