rameshrai
Full Member level 3

Hi, can anybody help with the code below. the code never output a(k)=1
I get the following result-
a(k)=1 never happens, i.e I expected 1 in a output.
thanks
Code:
N=4;
for k=1:N;
select(k)=rand;
if (0<select(k)<0.5)
a(k)=1;
elseif (0.5<select(k)<1),
a(k)=2;
end
end
I get the following result-
>> a
a =
0 2 0 0
a(k)=1 never happens, i.e I expected 1 in a output.
thanks
Last edited by a moderator: