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:
Help Code

Subject: Help Code

From: Gauthaman parthiban

Date: 27 Apr, 2009 07:26:03

Message: 1 of 2

LIND = 15; % Length of individual vars.
NVAR = 2; % No. of decision variables
NIND = 40; % No. of individuals
GGAP = 0.9; % Generation gap
XOV = 0.7; % Crossover rate
MUTR = 0.0175; % Mutation rate
MAXGEN = 30; % No. of generations
% Binary representation scheme
FieldD = [LIND LIND; 1 1; 1000 1000; 1 1; 0 0; 0 0; 0 0];
% Initialise population
Chrom = crtbp(Nind, Lind*NVAR); % Create binary population
ObjV = objfun(bs2rv(Chrom, FieldD)); % Evaluate objective fn.
Gen = 0; % Counter
% Begin generational loop
while Gen < MAXGEN
% Assign fitness values to entire population
FitnV = ranking(ObjV);
% Visualisation
plotgraphics
% Select individuals for breeding
SelCh = select(’sus’, Chrom, FitnV, GGAP);
% Recombine individuals (crossover)
SelCh = recombin(’xovsp’, SelCh, XOV);
% Apply mutation
SelCh = mut(SelCh, MUTR);
% Evaluate offspring, call objective function
ObjVSel = objfun(bs2rv(SelCh, FieldD));
% Reinsert offspring into population
[Chrom ObjV]=reins(Chrom, SelCh, 1, 1, ObjV, ObjVSel);
% Increment counter
Gen = Gen+1;
end
% Convert Chrom to real-values
Phen = bs2rv(Chrom, FieldD);




If i execute this code in Matlab It is not working...........
Please help me............

Subject: Help Code

From: Steven Lord

Date: 27 Apr, 2009 13:47:44

Message: 2 of 2


"Gauthaman parthiban" <gauthaman.p@gmail.com> wrote in message
news:gt3mmb$21d$1@fred.mathworks.com...

*snip code*

> If i execute this code in Matlab It is not working...........
> Please help me............

Sounds like a perfect opportunity for you to learn how to debug your
programs in MATLAB. Read through these sections of the documentation and
use the tools and techniques they describe to locate the cause of the error
or unexpected behavior.

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/brqxeeu-147.html

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/brqxeeu-175.html

--
Steve Lord
slord@mathworks.com

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