Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: problem in if else !!!!!!!!!!!!
Replies: 1   Last Post: Apr 19, 2013 10:05 AM

 Messages: [ Previous | Next ]
 KARTIK ARG Posts: 1 Registered: 4/19/13
problem in if else !!!!!!!!!!!!
Posted: Apr 19, 2013 12:00 AM

in this prgm bin contains 0s and 1s in random.
now i want to print 'after mutation' when bin value contains 0 and 'after mu' when bin value contains 1.

clc;
clear all;
% >> Inititalizing Population...
m=0.47;s=5;
z=1;
popdec=cell(20,5);
popbin=cell(20,5);
vi(1,1)=0;low=0;
for i=1:20
for j=1:5
if j==1
lim=low+(80-low)*(rand);
popdec{i,j}=ceil(lim); % Generating random numbers b/w 1 to 90
z=j;
else
lim=popdec{i,z}+(90-popdec{i,z})*rand;
popdec{i,j}=ceil(lim);
z=j;
end
end
end

for i=1:20
for j=1:5
store=popdec{i,j}; % population in decimal
popbin{i,j}=dec2bin(store,8); % population in binary
end
end
bin=cell2mat(popbin);
for i=1:20
for j=1:40
z=mod(j,2);
if z==1
v1(1,1)=bin(i,j);
t=v1(1,1)
else
v2(1,1)=bin(i,j);
t=v2(1,1)
end

if t==0
disp('aftr mutation');

else
disp('aftr mut');
end
end
end

Date Subject Author
4/19/13 KARTIK ARG
4/19/13 Curious