MATLAB: Hi,,is there any way,I can generate a vector with 10 bit with only zero and 25

vector random with zero and 25

the vector should be like this, A=[0 0 25 25 25 0 0 25 0]…or anything that has only zero and 25.number of 25 is not important..TIA

Best Answer

TheConstant = 25;
HowMany = 10;
binary = rand(1,HowMany) < 0.5;
result = binary * TheConstant;
Or in short,
result = (rand(1,10) < 0.5) * 25;