R rameshrai Member Feb 28, 2014 #1 Hi, can anybody help with the code below. clc clear all N=4; a=zeros(1,N); 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 But, a(k)=1 never happens, i.e I expected 1 in a output. thanks
Hi, can anybody help with the code below. clc clear all N=4; a=zeros(1,N); 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 But, a(k)=1 never happens, i.e I expected 1 in a output. thanks