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

📄 ga_view1.m

📁 用MATLAB实现遗传算法中的好多问题
💻 M
字号:
%
% da_view1.m
%
% Views each variable in the data file
%

clg;
drawnow;
w1=gcf;

%
% Draw a set of axes
%
figure(w1);
ax1=axes;
set(ax1,...
	'Units','pixels',...
	'Position',[50 200 500 175],...
	'Box','on',...
	'Color',[0 0 0],...
	'Visible','on');

plot_var=1;
[D L]=size(data);
old_sl1_value=0;

%
% Set up a stats box
%

box1=uicontrol(w1,...
	'style','frame',...
	'position',[400 15 190 105],...
	'foregroundcolor',[0 0 1],...
	'backgroundcolor',[1 1 1]);

%
% Set up text objects in this box
%

text1=da_text(w1,440,100,120,15,['Current variable = ' num2str(plot_var)],[0 0 0],[1 1 1]);
text2=da_text(w1,405,80,175,15,['Minimum value = ' num2str(min(data(:,plot_var)))],[0 0 1],[1 1 1]);
text3=da_text(w1,405,60,175,15,['Maximum value = ' num2str(max(data(:,plot_var)))],[0 0 1],[1 1 1]);
text4=da_text(w1,405,40,175,15,['Standard deviation = ' num2str(std(data(:,plot_var)))],[0 0 1],[1 1 1]);
text5=da_text(w1,405,20,175,15,['Mean value           = ' num2str(mean(data(:,plot_var)))],[0 0 1],[1 1 1]);

%
% Now plot the variable
%

plot(data(:,plot_var));
set(ax1,'Xlim',[0 D]);
Xlabel('Sample number');
Ylabel('Value')

%
% Draw a slider to change the plotted variable
%

sl1=uicontrol(w1,...
	'style','slider',...
	'position',[100 100 150 20],...
	'Min',1,...
	'Max',L,...
	'Value',1,...
	'CallBack',[
		'sl1_value=ceil(get(sl1,''Value''));',...
		'if sl1_value ~= old_sl1_value;',...
			'old_sl1_value=sl1_value;',...
			'plot_var=sl1_value;',...
			'plot(data(:,plot_var));',...
			'Xlabel(''Sample number'');',...
			'Ylabel(''Value'');',...
			'set(ax1,''Xlim'',[0 D]);',...
			'set(text1,''string'',[''Current variable = '' num2str(plot_var)]);',...
			'set(text2,''string'',[''Minimum value = '' num2str(min(data(:,plot_var)))]);',...
			'set(text3,''string'',[''Maximum value = '' num2str(max(data(:,plot_var)))]);',...
			'set(text4,''string'',[''Standard deviation = '' num2str(std(data(:,plot_var)))]);',...
			'set(text5,''string'',[''Mean value           = '' num2str(mean(data(:,plot_var)))]);',...
			'set(text7,''string'',num2str(plot_var));',...
		'end;']);

text6=da_text(w1,60,125,150,15,'Select current variable = ',[1 1 1],[0 0 0]);
text7=da_text(w1,200,125,20,15,num2str(plot_var),[1 1 1],[0 0 0]);
text8=da_text(w1,80,100,18,15,'1',[1 1 1],[0 0 0]);
text9=da_text(w1,260,100,25,15,num2str(L),[1 1 1],[0 0 0]);


%
% Couple more lines of text saying how many variables there are etc
%

text10=da_text(w1,70,60,200,15,['Total number of variables = ' num2str(L)],[1 1 1],[1 0 0]);
text11=da_text(w1,70,40,200,15,['Total number of readings  = ' num2str(D)],[1 1 1],[1 0 0]);

⌨️ 快捷键说明

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