Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
problem in if else !!!!!!!!!!!!

Subject: problem in if else !!!!!!!!!!!!

From: KARTIK ARG

Date: 19 Apr, 2013 04:00:11

Message: 1 of 2

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

Subject: problem in if else !!!!!!!!!!!!

From: someone

Date: 19 Apr, 2013 14:05:09

Message: 2 of 2

"KARTIK ARG" <argkarthik@yahoo.com> wrote in message <kkqfgb$obt$1@newscl01ah.mathworks.com>...
> 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.

So, whats the problem? Whats your question?

>
> 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

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us