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

📄 da_selec.m

📁 这是好用的源代码
💻 M
字号:
%
% da_selec.m
%
% Allows the user to specify which variables
% to include, and which (if any) are designated output variables
%
% NOTE:
%	This screen allows multiple output variables to 
%	be selected. If the modelling routine does not
%	allow multiple outputs, then it should take only
%	the FIRST output variable in the list output_var.
%

da_front;
drawnow;
w1=gcf;
selec_var=1;
old_sl1_value=selec_var;
%
% Draw three buttons
%
% but1 = Include this variable
% but2 = Define this as one of the output variabes
% but3 = Bin this variable
%

but1=uicontrol(w1,...
	'style','push',...
	'position',[400 350 200 20],...
	'string','Include this variable',...
	'callback',[
		'include_var(selec_var)=1;',...
		'set(text3,''string'',''Is included'');',...
		'set(text6,''string'',[num2str(sum(include_var)) '' Variables included'']);',...
		'set(text7,''string'',[num2str(sum(include_var)-sum(output_var)) '' Input variables'']);',...
		'set(text8,''string'',[num2str(sum(output_var)) '' Output variables'']);']);


		

but2=uicontrol(w1,...
	'style','push',...
	'position',[400 320 200 20],...
	'string','Exclude this variable',...
	'callback',[
		'include_var(selec_var)=0;',...
		'output_var(selec_var)=0;',...
		'set(text3,''string'',''Is NOT included'');',...
		'set(text4,''string'',''Is an INPUT variable'');',...
		'set(text6,''string'',[num2str(sum(include_var)) '' Variables included'']);',...
		'set(text8,''string'',[num2str(sum(output_var)) '' Output variables'']);',...
		'set(text7,''string'',[num2str(sum(include_var)-sum(output_var)) '' Input variables'']);']);

but3=uicontrol(w1,...
	'style','push',...
	'position',[400 290 200 20],...
	'string','Define this as an output',...
	'callback',[
		'output_var(selec_var)=1;',...
		'include_var(selec_var)=1;',...
		'set(text4,''string'',''Is an OUTPUT variable'');',...
		'set(text3,''string'',''Is included'');',...
		'set(text6,''string'',[num2str(sum(include_var)) '' Variables included'']);',...
		'set(text7,''string'',[num2str(sum(include_var)-sum(output_var)) '' Input variables'']);',...
		'set(text8,''string'',[num2str(sum(output_var)) '' Output variables'']);']);


but4=uicontrol(w1,...
	'style','push',...
	'position',[400 260 200,20],...
	'string','Define this as an input',...
	'callback',[
		'output_var(selec_var)=0;',...
		'set(text4,''string'',''Is an INPUT variable'');',...
		'set(text7,''string'',[num2str(sum(include_var)-sum(output_var)) '' Input variables'']);',...
		'set(text8,''string'',[num2str(sum(output_var)) '' Output variables'']);']);

%
% Text object that says which variable is current
%

text1=da_text(w1,120,350,150,15,['Current variable = ' num2str(selec_var)],[1 1 1],[1 0 0]);

%
% Text that gives information about a variables status
%

text2=da_text(w1,20,300,100,15,'This variable',[1 1 1],[0 0 0]);
text3=da_text(w1,120,300,150,15,'Is included',[1 1 1],[0 0 1]);
text4=da_text(w1,120,280,150,15,'Is an INPUT variable',[1 1 1],[0 0 1]);

%
% Set these correctly
%

if include_var(selec_var) == 0
	set(text3,'String','Is NOT included');
elseif output_var(selec_var) == 1
	set(text4,'String','Is an OUTPUT variable');
end

%
% Set up a list in a box, saying how many variables are
% included, and what they are:
%

box1=uicontrol(w1,...
	'style','frame',...
	'position',[400 115 200 100],...
	'Foregroundcolor',[0 0 1],...
	'Backgroundcolor',[1 1 1]);

%
% Put the text into this box:
%

text5=da_text(w1,405,196,190,15,'There are:',[1 1 1],[0 0 1]);
text6=da_text(w1,405,170,185,15,[num2str(sum(include_var)) ' Variables included'],[0 0 1],[1 1 1]);
text7=da_text(w1,405,150,185,15,[num2str(sum(include_var)-sum(output_var)) ' Input variables'],[0 0 1],[1 1 1]);
text8=da_text(w1,405,130,185,15,[num2str(sum(output_var)) ' Output variables'],[0 0 1],[1 1 1]);


%
% Plot the current variable
%
ax1=axes;
set(ax1,...
	'Units','pixels',...
	'Position',[40 115 310 100],...
	'Box','on',...
	'Color',[0 0 0],...
	'Visible','on');

plot(data(:,selec_var));
[D L]=size(data);
set(ax1,'Xlim',[0 D]);


%
% Now set up a slider to determine the current variable
%

sl1=uicontrol(w1,...
	'style','slider',...
	'position',[125 40 150 20],...
	'min',1,...
	'Max',L,...
	'value',selec_var,...
	'Callback',[
		'sl1_value=ceil(get(sl1,''Value''));',...
		'if sl1_value ~= old_sl1_value;',...
			'old_sl1_value=sl1_value;',...
			'selec_var=sl1_value;',...
			'set(text1,''string'',[''Current variable = '' num2str(selec_var)]);',...
			'if output_var(selec_var) == 1;',...
				'set(text4,''string'',''Is an OUTPUT variable'');',...
			'else;',...
				'set(text4,''string'',''Is an INPUT variable'');',...
			'end;',...
			'if include_var(selec_var) == 1;',...
				'set(text3,''string'',''Is included'');',...
			'else;',...
				'set(text3,''string'',''Is NOT included'');',...
			'end;',...
			'plot(data(:,selec_var));',...
			'set(ax1,''Xlim'',[0 D]);',...
		'end;']);

%
% Text objects for the slider
%

text9=da_text(w1,105,40,15,15,'1',[1 1 1],[0 0 0]);
text10=da_text(w1,280,40,20,15,num2str(L),[1 1 1],[0 0 0]);
text11=da_text(w1,30,60,200,15,'Select the current variable:',[1 1 1],[0 0 0]);

⌨️ 快捷键说明

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