Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

New Articles From Microcontroller Tips

Back
Top