Matlab problem

Status
Not open for further replies.

rameshrai

Member
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
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…