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

📄 rgen123.m

📁 一个利用元胞自动机进行生态仿真的matlab程序
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RGEN123
% Rule generator for 1-dimensional CA
% when number of states is 2 and when number of neighbors is 3
% This script-M file is called by RULEGEN1
%
%	Fist Coded			27  March    1997
%	Last Modefied		20   August    1997
%
%	Copyright (c)
%	T. Suzudo JAERI-CAIL
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cleanup='clear string1 r_hand* tr_hand* x y dx dy 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','Ecodynamica Rule Generator for 1 dimension K=2 N=3',...
		'Fontsize',12,...
		'foregroundcolor','red',...
		'Units','normalized',...
		'position',[0,y,1,dy]);

%totalistic rule
if ltot==1
	tr_hand=zeros(lnei+1,1);
	x=x0+wx;
	for ii=1:lnei+1
		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_code123(ii),...
			'CallBack','uprule1');
	end
	distot(tr_code123,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_code123(ii),...
			'CallBack','uprule1');
		lambda=lambda+combi(lnei-1,rem(ii-1,lnei))*otr_code123(ii);
	end
	y=disout(otr_code123,lnei,4*dy);
	lambda=lambda/2^(lnei);
	y=y-dy;
	uicontrol(fig11,'Style','text',...
					'String',['lambda = ' num2str(lambda)],...
					'Units','normalized',...
					'position',[x0,y,0.8,dy]);
% General rule
elseif ltot==3
y=y0-dy;
r_hand1=uicontrol(fig11,'Style','checkbox',...
		'Units','normalized',...
		'Position',[x y wx dy],...
		'String',decode(1,2),... 
		'Value',r_code123(1),...
		'CallBack',['r_code123(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),... 
		'Value',r_code123(2),...
		'CallBack',['r_code123(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),... 
		'Value',r_code123(3),...
		'CallBack',['r_code123(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),... 
		'Value',r_code123(4),...
		'CallBack',['r_code123(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),... 
		'Value',r_code123(5),...
		'CallBack',['r_code123(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),... 
		'Value',r_code123(6),...
		'CallBack',['r_code123(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),... 
		'Value',r_code123(7),...
		'CallBack',['r_code123(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),... 
		'Value',r_code123(8),...
		'CallBack',['r_code123(8)=get(r_hand8,''Value'');']);
% Legal or Illigal
y=y-2*dy;
if (r_code123(1) | r_code123(2)~=r_code123(5) | r_code123(4)~=r_code123(7) )
	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=2*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 'rgen123;']);
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 + -