⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rgen125.m

📁 一个利用元胞自动机进行生态仿真的matlab程序
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RGEN125
% Rule generator for 1-dimensional CA
% when number of states is 2 and when number of neighbors is 5
% This script-M file is called by RULEGEN1
%
%	Fist Coded			22  April  1997
%	Last Modefied		22  April  1998
%
%	Copyright (c)
%	T. Suzudo JAERI-CAIL
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cleanup='clear string1 r_hand* tr_hand* x y x0 y0 ;';

fig11=figure(11);

x0 = 0.1;
y0 = 0.95;
dx = 0.012;
dy = 0.05;
wx = 0.25;

% Title
x=x0;
y=y0;
uicontrol(fig11,'Style','text','String','Rule Generator for 1 dimension K=2 N=5',...
		'Fontsize',12,...
		'foregroundcolor','red',...
		'Units','normalized',...
		'position',[0,y,1,dy]);

%totalistic rule
if ltot==1
	tr_hand=zeros(lnei+1,1);
	for ii=1:lnei+1
		x=x0+wx;
		y=y0-ii*dy;
		tr_hand(ii)=uicontrol(fig11,'Style','checkbox',...
			'Units','normalized',...
			'Position',[x y wx dy],...
			'String',['Total ' num2str(ii-1)],... 
			'Value',tr_code125(ii),...
			'CallBack','uprule1');
	end
	distot(tr_code125,lnei);
%Outer-totalistic rule
elseif ltot==2
	lambda=0;
	tr_hand=zeros(lnei*2,1);
	for ii=1:lnei*2
		x=x0+wx*(fix((ii-1)/lnei)+1);
		y=y0-(rem(ii-1,lnei)+1)*dy;
		if ii<lnei+1
			string1=['Self OFF Outer Total ' num2str(ii-1)];
		else
			string1=['Self ON Outer Total ' num2str(ii-1-lnei)];
		end
		tr_hand(ii)=uicontrol(fig11,'Style','checkbox',...
			'Units','normalized',...
			'Position',[x y wx dy],...
			'String',string1,... 
			'Value',otr_code125(ii),...
			'CallBack','uprule1');
		lambda=lambda+combi(lnei-1,rem(ii-1,lnei))*otr_code125(ii);
	end
	y=disout(otr_code125,lnei);
	lambda=lambda/2^(lnei);
	y=y-dy;
	uicontrol(fig11,'Style','text',...
					'String',['lambda = ' num2str(lambda)],...
					'Units','normalized',...
					'position',[x0,y,0.8,dy]);
% Genral rule
elseif ltot==3
y=y0-dy;
r_hand1=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(1,2,5),... 
		'Value',r_code125(1),...
		'CallBack',['r_code125(1)=get(r_hand1,''Value'');']);
y=y-dy;
r_hand2=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(2,2,5),... 
		'Value',r_code125(2),...
		'CallBack',['r_code125(2)=get(r_hand2,''Value'');']);
y=y-dy;
r_hand3=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(3,2,5),... 
		'Value',r_code125(3),...
		'CallBack',['r_code125(3)=get(r_hand3,''Value'');']);
y=y-dy;
r_hand4=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(4,2,5),... 
		'Value',r_code125(4),...
		'CallBack',['r_code125(4)=get(r_hand4,''Value'');']);
y=y-dy;
r_hand5=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(5,2,5),... 
		'Value',r_code125(5),...
		'CallBack',['r_code125(5)=get(r_hand5,''Value'');']);
y=y-dy;
r_hand6=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(6,2,5),... 
		'Value',r_code125(6),...
		'CallBack',['r_code125(6)=get(r_hand6,''Value'');']);
y=y-dy;
r_hand7=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(7,2,5),... 
		'Value',r_code125(7),...
		'CallBack',['r_code125(7)=get(r_hand7,''Value'');']);
y=y-dy;
r_hand8=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(8,2,5),... 
		'Value',r_code125(8),...
		'CallBack',['r_code125(8)=get(r_hand8,''Value'');']);

x=x+wx;
y=y0-dy;
r_hand9=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(9,2,5),... 
		'Value',r_code125(9),...
		'CallBack',['r_code125(9)=get(r_hand9,''Value'');']);
y=y-dy;
r_hand10=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(10,2,5),... 
		'Value',r_code125(10),...
		'CallBack',['r_code125(10)=get(r_hand10,''Value'');']);
y=y-dy;
r_hand11=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(11,2,5),... 
		'Value',r_code125(11),...
		'CallBack',['r_code125(11)=get(r_hand11,''Value'');']);
y=y-dy;
r_hand12=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(12,2,5),... 
		'Value',r_code125(12),...
		'CallBack',['r_code125(12)=get(r_hand12,''Value'');']);
y=y-dy;
r_hand13=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(13,2,5),... 
		'Value',r_code125(13),...
		'CallBack',['r_code125(13)=get(r_hand13,''Value'');']);
y=y-dy;
r_hand14=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(14,2,5),... 
		'Value',r_code125(14),...
		'CallBack',['r_code125(14)=get(r_hand14,''Value'');']);
y=y-dy;
r_hand15=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(15,2,5),... 
		'Value',r_code125(15),...
		'CallBack',['r_code125(15)=get(r_hand15,''Value'');']);
y=y-dy;
r_hand16=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(16,2,5),... 
		'Value',r_code125(16),...
		'CallBack',['r_code125(16)=get(r_hand16,''Value'');']);

x=x+wx;
y=y0-dy;
r_hand17=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(17,2,5),... 
		'Value',r_code125(17),...
		'CallBack',['r_code125(17)=get(r_hand17,''Value'');']);
y=y-dy;
r_hand18=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(18,2,5),... 
		'Value',r_code125(18),...
		'CallBack',['r_code125(18)=get(r_hand18,''Value'');']);
y=y-dy;
r_hand19=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(19,2,5),... 
		'Value',r_code125(19),...
		'CallBack',['r_code125(19)=get(r_hand19,''Value'');']);
y=y-dy;
r_hand20=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(20,2,5),... 
		'Value',r_code125(20),...
		'CallBack',['r_code125(20)=get(r_hand20,''Value'');']);
y=y-dy;
r_hand21=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(21,2,5),... 
		'Value',r_code125(21),...
		'CallBack',['r_code125(21)=get(r_hand21,''Value'');']);
y=y-dy;
r_hand22=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(22,2,5),... 
		'Value',r_code125(22),...
		'CallBack',['r_code125(22)=get(r_hand22,''Value'');']);
y=y-dy;
r_hand23=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(23,2,5),... 
		'Value',r_code125(23),...
		'CallBack',['r_code125(23)=get(r_hand23,''Value'');']);
y=y-dy;
r_hand24=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(24,2,5),... 
		'Value',r_code125(24),...
		'CallBack',['r_code125(24)=get(r_hand24,''Value'');']);

x=x+wx;
y=y0-dy;
r_hand25=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(25,2,5),... 
		'Value',r_code125(25),...
		'CallBack',['r_code125(25)=get(r_hand25,''Value'');']);
y=y-dy;
r_hand26=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(26,2,5),... 
		'Value',r_code125(26),...
		'CallBack',['r_code125(26)=get(r_hand26,''Value'');']);
y=y-dy;
r_hand27=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(27,2,5),... 
		'Value',r_code125(27),...
		'CallBack',['r_code125(27)=get(r_hand27,''Value'');']);
y=y-dy;
r_hand28=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(28,2,5),... 
		'Value',r_code125(28),...
		'CallBack',['r_code125(28)=get(r_hand28,''Value'');']);
y=y-dy;
r_hand29=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(29,2,5),... 
		'Value',r_code125(29),...
		'CallBack',['r_code125(29)=get(r_hand29,''Value'');']);
y=y-dy;
r_hand30=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(30,2,5),... 
		'Value',r_code125(30),...
		'CallBack',['r_code125(30)=get(r_hand30,''Value'');']);
y=y-dy;
r_hand31=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(31,2,5),... 
		'Value',r_code125(31),...
		'CallBack',['r_code125(31)=get(r_hand31,''Value'');']);
y=y-dy;
r_hand32=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(32,2,5),... 
		'Value',r_code125(32),...
		'CallBack',['r_code125(32)=get(r_hand32,''Value'');']);
% Legal or Illigal
	x=0.5-wx/2;
	y=y-2*dy;
	if (r_code125(1) | ...
      r_code125(2)~=r_code125(17) | ...
      r_code125(3)~=r_code125(9) | ...
      r_code125(4)~=r_code125(25) | ...
      r_code125(6)~=r_code125(21) | ...
      r_code125(7)~=r_code125(13) | ...
      r_code125(8)~=r_code125(29) | ...
      r_code125(10)~=r_code125(19) | ...
      r_code125(12)~=r_code125(27) | ...
      r_code125(14)~=r_code125(23) | ...
      r_code125(16)~=r_code125(31) | ...
      r_code125(20)~=r_code125(26) | ...
      r_code125(24)~=r_code125(30) )
   string1='Illegal rule';
else
   string1='Legal rule';
end
uicontrol(fig11,'Style','text','String',string1,...
   'Fontsize',10,...
   'foregroundcolor','red',...
   'Units','normalized',...
   'position',[x,y,wx,dy]);

end

% Determination of the parameters
%
x=x0;
y=dy;
uicontrol(fig11,'Style','push',...
		'Units','normalized',...
		'Position',[x y 0.15 dy],...
		'String','OK',...
		'CallBack',[rc1save 'close(fig11);' cleanup] );
uicontrol(fig11,'Style','push',...
		'Units','normalized',...
		'Position',[x+1/3 y 0.15 dy],...
		'String','Apply',...
		'CallBack',[rc1save 'close(fig11);' cleanup 'rgen125;']);
uicontrol(fig11,'Style','push',...
		'Units','normalized',...
		'Position',[x+2/3 y 0.15 dy],...
		'String','RUN',...
		'CallBack',[rc1save 'close(fig11);' cleanup 'figure(1); runeco1;'] );

⌨️ 快捷键说明

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