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

📄 da_spike.m

📁 王小平《遗传算法——理论、应用与软件实现》随书光盘
💻 M
字号:
% da_filt.m
%
% Screen to show prefiltered and postfiltered variable and stats
% Calls in appropriate filter function depending upon users choice.
% Written by A. Mitchell (7/12/95)
%
% Calls:	remspike(a,x)
%
% where	x = tolerance multiplier
%		a = prefiltered data
%

clg;
da_front;
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');

%
% Initialisation
%
tol_mult=1.0;
plot_var=1;
[D L]=size(data);
old_sl1_value=0;
old_sl2_value=0;
sl1_value=1;
sl2_value=1.0;

%
% filter the data
%
   fil_data=remspike(data(:,plot_var),tol_mult);

%
% Set up a stats box for prefiltered data
%
box1=uicontrol(w1,...
	'style','frame',...
	'position',[50 15 210 105],...
	'foregroundcolor',[0 0 1],...
	'backgroundcolor',[1 1 1]);

%
% Set up text objects in this box
%
text1=da_text(w1,55,100,190,15,['Prefiltered Stats Var.' num2str(plot_var)],[0 0 0],[1 1 1]);
text2=da_text(w1,55,80,190,15,['Minimum value = ' num2str(min(data(:,plot_var)))],[0 0 1],[1 1 1]);
text3=da_text(w1,55,65,190,15,['Maximum value = ' num2str(max(data(:,plot_var)))],[0 0 1],[1 1 1]);
text4=da_text(w1,55,50,190,15,['Standard deviation = ' num2str(std(data(:,plot_var)))],[0 0 1],[1 1 1]);
text5=da_text(w1,55,35,190,15,['Mean value = ' num2str(mean(data(:,plot_var)))],[0 0 1],[1 1 1]);
text12=da_text(w1,55,20,190,15,['Median value = ' num2str(median(data(:,plot_var)))],[0 0 1],[1 1 1]);

%
% Set up a stats box for postfiltered data
%
box2=uicontrol(w1,...
	'style','frame',...
	'position',[350 15 210 105],...
	'foregroundcolor',[0 0 1],...
	'backgroundcolor',[1 1 1]);

%
% Set up text objects in this box
%
text21=da_text(w1,355,100,190,15,['Postfiltered Stats Var.' num2str(plot_var)],[0 0 0],[1 1 1]);
text22=da_text(w1,355,80,190,15,['Minimum value = ' num2str(min(fil_data(:,plot_var)))],[0 0 1],[1 1 1]);
text23=da_text(w1,355,65,190,15,['Maximum value = ' num2str(max(fil_data(:,plot_var)))],[0 0 1],[1 1 1]);
text24=da_text(w1,355,50,190,15,['Standard deviation = ' num2str(std(fil_data(:,plot_var)))],[0 0 1],[1 1 1]);
text25=da_text(w1,355,35,190,15,['Mean value = ' num2str(mean(fil_data(:,plot_var)))],[0 0 1],[1 1 1]);
text212=da_text(w1,355,20,190,15,['Median value = ' num2str(median(fil_data(:,plot_var)))],[0 0 1],[1 1 1]); 

%
% Now plot the variable
%
stairs(data(:,plot_var));
set(ax1,'Xlim',[0 D]);
Xlabel('Sample number');
Ylabel('Value');
hold on;
plot(fil_data,'m');
hold off;

sl1=uicontrol(w1,...
	'style','slider',...
	'position',[390 130 150 20],...
	'Min',1,...
	'Max',L,...
	'Value',1,...
	'CallBack',[
		'set(sl1_current,''String'',ceil(get(sl1,''Value'')));',...
		'sl1_value=ceil(get(sl1,''Value''));',...
		'if sl1_value ~= old_sl1_value;',...
			'set(sl1_current,''String'',num2str(ceil(sl1_value)));',...
			'old_sl1_value=sl1_value;',...
			'plot_var=sl1_value;',...
			'stairs(data(:,plot_var));',...
               'fil_data=remspike(data(:,plot_var),tol_mult);',...
			'hold on;',...
                        'plot(fil_data,''m'');',...
                        'hold off;',...
			'Xlabel(''Sample number'');',...
			'Ylabel(''Value'');',...
			'set(ax1,''Xlim'',[0 D]);',...
			'set(text1,''string'',[''Prefiltered Stats Var.'' 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(text12,''string'',[''Median value = '' num2str(median(data(:,plot_var)))]);',...
			'set(text21,''string'',[''Postfiltered Stats Var.'' num2str(plot_var)]);',...
			'set(text22,''string'',[''Minimum value = '' num2str(min(fil_data))]);',...
			'set(text23,''string'',[''Maximum value = '' num2str(max(fil_data))]);',...
			'set(text24,''string'',[''Standard deviation = '' num2str(std(fil_data))]);',...
			'set(text25,''string'',[''Mean value = '' num2str(mean(fil_data))]);',...
			'set(text212,''string'',[''Median value = '' num2str(median(fil_data))]);',...
		'end;']);

sl1_current=uicontrol(w1,...
	'Style','text',...
	'Position',[530,150,20,15],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String',num2str(get(sl1,'Value')));

sl1_min=uicontrol(w1,...
	'Style','text',...
	'Position',[370,130,18,15],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String','1');

sl1_max=uicontrol(w1,...
	'Style','text',...
	'Position',[550,130,25,15],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String',num2str(L));

sl1_title=uicontrol(w1,...
	'Style','text',...
	'Position',[380,150,150,15],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String','Current variable =');

%
% Draw a slider to change the tolerance multiplier
%

sl2=uicontrol(w1,...
	'style','slider',...
	'position',[50 130 150 20],...
	'Min',0,...
	'Max',2,...
	'Value',sl2_value,...
	'CallBack',[
		'set(sl2_current,''String'',ceil(100*(get(sl2,''Value'')))/100);',...
		'sl2_value=ceil(100*(get(sl2,''Value'')))/100;',...
		'if sl2_value ~= old_sl2_value;',...
			'set(sl1_current,''String'',num2str(ceil(sl1_value)));',...
			'old_sl2_value=sl2_value;',...
			'tol_mult=sl2_value;',...
			'stairs(data(:,plot_var));',...
               'fil_data=remspike(data(:,plot_var),tol_mult);',...
			'hold on;',...
                        'plot(fil_data,''m'');',...
                        'hold off;',...
			'Xlabel(''Sample number'');',...
			'Ylabel(''Value'');',...
			'set(ax1,''Xlim'',[0 D]);',...
			'set(text1,''string'',[''Prefiltered Stats Var.'' 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(text12,''string'',[''Median value = '' num2str(median(data(:,plot_var)))]);',...
			'set(text21,''string'',[''Postfiltered Stats Var.'' num2str(plot_var)]);',...
			'set(text22,''string'',[''Minimum value = '' num2str(min(fil_data))]);',...
			'set(text23,''string'',[''Maximum value = '' num2str(max(fil_data))]);',...
			'set(text24,''string'',[''Standard deviation = '' num2str(std(fil_data))]);',...
			'set(text25,''string'',[''Mean value = '' num2str(mean(fil_data))]);',...
			'set(text212,''string'',[''Median value = '' num2str(median(fil_data))]);',...
		'end;']);

sl2_current=uicontrol(w1,...
	'Style','text',...
	'Position',[185,150,50,15],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String',num2str(get(sl2,'Value')));

sl2_min=uicontrol(w1,...
	'Style','text',...
	'Position',[30,130,18,15],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String','0');

sl2_max=uicontrol(w1,...
	'Style','text',...
	'Position',[220,130,25,15],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String','2');

sl2_title=uicontrol(w1,...
	'Style','text',...
	'Position',[30,150,150,15],...
	'BackGroundColor',[0 0 0],...
	'ForeGroundColor',[1 1 1],...
	'String','Tolerance Multiplier =');

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

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

but7=uicontrol(w1,...
	'style','push',...
	'position',[400 380 175 20],...
	'string','ACCEPT changes',...
	'Callback',[
		'data(:,plot_var)=fil_data'';',...
		'axes(ax1);']);

⌨️ 快捷键说明

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