getreal.m

来自「多智能体工具包」· M 代码 · 共 24 行

M
24
字号
function RealValue=getreal(ThisChromsome)
% GETREAL	Return the corresponding value of the chromosome.

%     Copyright (c) 1998-2000 Jiming Liu and Jianbing Wu

global RegionCodeLen DirectCodeLen RobotNum;

RealValue=[];
% Deal with the POSITION
for loop1=1:RobotNum
  GrayCode=ThisChromsome((loop1-1)*RegionCodeLen+1:loop1*RegionCodeLen);
  BinCode=gray2bin(GrayCode);
  IntValue=bin2int(BinCode);
  RealValue=[RealValue IntValue];
end;

% Deal with the DIRECTION
for loop1=RobotNum+1:RobotNum*2
  GrayCode=ThisChromsome((loop1-1)*DirectCodeLen+1:loop1*DirectCodeLen);
  BinCode=gray2bin(GrayCode);
  IntValue=bin2int(BinCode);
  RealValue=[RealValue IntValue];
end;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?