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

📄 plotmap.m

📁 一个matlab的将军模型
💻 M
字号:

%-----------------------------------------------------------------------%
% Function  	: PlotMap                               CREATOR: Izaias  %  
% Credate    	: 072099		                            CURDATE:072099   %
% Description	: This function draw the polytope related with each      %
%                location reachable from the initial locations.         %
%-----------------------------------------------------------------------%
% Functional Description:                                               % 
%  Load  GLOBAL_PIHA.InitialLocation to initloc                         %
%  Plot polytopes of initloc using GLOBAL_AUTOMATON    						%
%  NOT_END = 1;																			%
%  actloc  = states from initloc using GLOBAL_TRANSITION ;																	%
%  nextloc = 0;																			%
%  while NOT_END 																			%
%     nextloc = next locations of actloc using GLOBAL_TRANSITION			%
%     remove redundancy of nextloc													%
%		plot polytopes of nextloc using GLOBAL_XSYS2AUTO_MAP					%
%		sort actloc and nextloc															%
%		if actloc==nextloc OR nextloc == 0											%
% 			NOT_END = 0																		%
%		end																					%
%	end																						%


% clear figure and make initial arrangements to plot
clf;
hold on;

%  Load  GLOBAL_PIHA.InitialLocation to initloc                         %
initloc = GLOBAL_PIHA.InitialLocations;


%  Plot polytopes of initloc using GLOBAL_AUTOMATON    						%
for i= 1:length(initloc)
   for j= 1:length(GLOBAL_AUTOMATON{i}.initstate)
      for k = 1:length(GLOBAL_AUTOMATON{i}.initstate{j}.mapping)
       	for m = 1:length(GLOBAL_AUTOMATON{i}.initstate{j}.mapping{k})
   			plot(GLOBAL_AUTOMATON{i}.initstate{j}.mapping{k}{m});		
      	end
  		end
   end
end
NOT_END = 1;

actloc  = unique(initloc);
nextloc = 0;
counter = 1;

%  Plot 'tree' of polytopes using GLOBAL_AUTOMATON    						%
while NOT_END
   for i=1:length(actloc)
      nextloc = [nextloc GLOBAL_TRANSITION{actloc(i)}];
   end
   if nextloc(1)==0
      nextloc = nextloc(2:length(nextloc));
   end
   nextloc	= unique(nextloc);
   if compvec(nextloc,actloc)
      NOT_END =0;
   else
 	   actloc = nextloc;
     	counter = counter + 1;
   end
end

fprintf('Drawing  polytopes, please wait... ');
for i= 1:length(nextloc)
   var_location 	= GLOBAL_XSYS2AUTO_MAP{nextloc(i)}(1);
   if ~(strcmp(var_location,'terminal'))
   	var_face			= GLOBAL_XSYS2AUTO_MAP{nextloc(i)}(2);
      var_state		= GLOBAL_XSYS2AUTO_MAP{nextloc(i)}(3);
   	for j= 1:length(GLOBAL_AUTOMATON{var_location}.face{var_face}.state{var_state}.mapping)
     		for k = 1:length(GLOBAL_AUTOMATON{var_location}.face{var_face}.state{var_state}.mapping{j})
   				plot(GLOBAL_AUTOMATON{var_location}.face{var_face}.state{var_state}.mapping{j}{k})		
      	end
  		end
   end
end
fprintf('done! \n');

⌨️ 快捷键说明

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