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

📄 miden.m

📁 王小平《遗传算法——理论、应用与软件实现》随书光盘
💻 M
📖 第 1 页 / 共 2 页
字号:
%
% Create axes to plot data on for output and input respecively
%
	if exist('pic_ax')==1
		axes(pic_ax);
		cla;
	end
	if exist('pic_ax1')==1
		axes(pic_ax1);
		cla;
	end

        [ID IL]=size(input_data);
	axes(pic_ax);
	axis([0 time_data(D,1) min(output_data) max(output_data)]);
	grid on;
	hold on;
	cla;
	drawnow;

	axes(pic_ax1);
	axis([0 time_data(D,1) min(input_data(:,input_fit))-0.25*(max(input_data(:,input_fit))-min(input_data(:,input_fit))) max(input_data(:,input_fit))+0.25*(max(input_data(:,input_fit))-min(input_data(:,input_fit)))]);
	end;
	grid on;

output_mean = mean(output_data);
for i=1:1:IL
	input_mean(i)=mean(input_data(:,i));
end

%
% Display the name of the output and input variables respectively
%
	out_disp=uicontrol(main,...
		'Style','Text',...
		'ForegroundColor',[1 1 1],...
		'BackgroundColor',[0 0 1],...
		'Units','Pixels',...
		'Position',[250 350 60 15],...
		'String',output_name);

	in_disp=uicontrol(main,...
		'Style','Text',...
		'ForegroundColor',[1 1 1],...
		'BackgroundColor',[0 0 1],...
		'Units','Pixels',...
		'Position',[250 168 60 15],...
		'String',input_name(input_fit,:));

%
%       setting background frames for sliders on figure window
%

t=data(:,time_var);
y=data(:,output_var);
u=data(:,input_var);

for i=1:1:ID
	modified_u(i,:) = input_data(i,:) - uss;
end
modified_y = output_data - yss;

%
% ***** Routine to draw the back-ground of the sliders ****
%	
	slifrm;
	slifrm1;
%
% Create the first slider
%
w1=main;
sl1_value=curr_vector(1,input_fit);
max1=max_vector(1,input_fit);
min1=min_vector(1,input_fit);

sl1=uicontrol(w1,...
	'style','slider',...
	'position',[65 110 70 15],...
	'BackgroundColor',[0.75 0.75 0.75],...
	'Min',min1,...
	'Max',max1,...
	'Value',sl1_value,...
	'CallBack',[
		'sl1_value=(get(sl1,''Value''));',...
		'set(text7,''string'',num2str(get(sl1,''Value'')));',...
		'if input_fit==1;',...
	 		'set_param(''midenmdl/Transfer Fcn1'',''Numerator'', get(sl1,''Value''));',...
		'elseif input_fit==2;',...
	 		'set_param(''midenmdl/Transfer Fcn2'',''Numerator'', get(sl1,''Value''));',...
		'elseif input_fit==3;',...
	 		'set_param(''midenmdl/Transfer Fcn3'',''Numerator'', get(sl1,''Value''));',...
		'elseif input_fit==4;',...
	 		'set_param(''midenmdl/Transfer Fcn4'',''Numerator'', get(sl1,''Value''));',...
		'elseif input_fit==5;',...
	 		'set_param(''midenmdl/Transfer Fcn5'',''Numerator'', get(sl1,''Value''));',...
		'elseif input_fit==6;',...
	 		'set_param(''midenmdl/Transfer Fcn6'',''Numerator'', get(sl1,''Value''));',...
		'elseif input_fit==7;',...
	 		'set_param(''midenmdl/Transfer Fcn7'',''Numerator'', get(sl1,''Value''));',...
		'elseif input_fit==8;',...
	 		'set_param(''midenmdl/Transfer Fcn8'',''Numerator'', get(sl1,''Value''));',...
		'elseif input_fit==9;',...
	 		'set_param(''midenmdl/Transfer Fcn9'',''Numerator'', get(sl1,''Value''));',...
		'end;',...
			'curr_vector(1,input_fit)=sl1_value;',...
		'drawnow;']);

text6=da_text(w1,50,125,50,15,'Kp =',[0 0 0],[1 1 1]);
text7=uicontrol(w1,...
	'Style','Text',...
	'Position',[90 125 90 15],...
	'String',num2str(sl1_value),...
	'ForegroundColor',[0 0 0],...
	'BackgroundColor',[1 1 1]);
%
% Change the maximum limit of the slider using edit-able text option
%

sl1_max=uicontrol(w1,...
	'style','edit',...
	'position',[140 110 40 15],...
	'string',num2str(max1),...		%get the current vale of the variable
	'foregroundcolor',[0 0 0],...
	'backgroundcolor',[1 1 1],...
	'callback',[
		'max1=str2num(get(sl1_max,''string''));',...  %read in the new value that the user has typed
		'set(sl1,''Max'',max1);',...
		'max_vector(1,input_fit)=max1;']);  %set the variable 'max' related to slider object sl1 to the value of fart
%
% Change the minimum limit of the slider using edit-able text option
%

sl1_min=uicontrol(w1,...
	'style','edit',...
	'position',[25 110 35 15],...
	'string',num2str(min1),...		%get the current vale of the variable
	'foregroundcolor',[0 0 0],...
	'backgroundcolor',[1 1 1],...
	'callback',[
		'min1=str2num(get(sl1_min,''string''));',...  %read in the new value that the user has typed
		'set(sl1,''Min'',min1);',...
		'min_vector(1,input_fit)=min1;']);  %set the variable 'max' related to slider object sl1 to the value of fart

sl2_value=curr_vector(2,input_fit);
max2=max_vector(2,input_fit);
min2=min_vector(2,input_fit);

sl2=uicontrol(w1,...
	'style','slider',...
	'position',[65 65 70 15],...
	'BackgroundColor',[0.75 0.75 0.75],...
	'Min',min2,...
	'Max',max2,...
	'Value',sl2_value,...
	'CallBack',[
		'sl2_value=(get(sl2,''Value''));',...
		'set(text11,''string'',num2str(get(sl2,''Value'')));',...
		'if input_fit==1;',...
			'set_param(''midenmdl/Transfer Fcn1'',''Denominator'',[(get(sl2,''Value'')) 1]);',...
		'elseif input_fit==2;',...
			'set_param(''midenmdl/Transfer Fcn2'',''Denominator'',[(get(sl2,''Value'')) 1]);',...
		'elseif input_fit==3;',...
			'set_param(''midenmdl/Transfer Fcn3'',''Denominator'',[(get(sl2,''Value'')) 1]);',...
		'elseif input_fit==4;',...
			'set_param(''midenmdl/Transfer Fcn4'',''Denominator'',[(get(sl2,''Value'')) 1]);',...
		'elseif input_fit==5;',...
			'set_param(''midenmdl/Transfer Fcn5'',''Denominator'',[(get(sl2,''Value'')) 1]);',...
		'elseif input_fit==6;',...
			'set_param(''midenmdl/Transfer Fcn6'',''Denominator'',[(get(sl2,''Value'')) 1]);',...
		'elseif input_fit==7;',...
			'set_param(''midenmdl/Transfer Fcn7'',''Denominator'',[(get(sl2,''Value'')) 1]);',...
		'elseif input_fit==8;',...
			'set_param(''midenmdl/Transfer Fcn8'',''Denominator'',[(get(sl2,''Value'')) 1]);',...
		'elseif input_fit==9;',...
			'set_param(''midenmdl/Transfer Fcn9'',''Denominator'',[(get(sl2,''Value'')) 1]);',...
		'end;',...
			'curr_vector(2,input_fit)=sl2_value;',...
		'drawnow;']);

text10=da_text(w1,50,80,50,15,'Tp =',[0 0 0],[1 1 1]);
text11=uicontrol(w1,...
	'Style','Text',...
	'Position',[90 80 60 15],...
	'String',num2str(sl2_value),...
	'ForegroundColor',[0 0 0],...
	'BackgroundColor',[1 1 1]);

%
% Change the maximum limit of the slider using edit-able text option
%

sl2_max=uicontrol(w1,...
	'style','edit',...
	'position',[140 65 40 15],...
	'string',num2str(max2),...		%get the current vale of the variable
	'foregroundcolor',[0 0 0],...
	'backgroundcolor',[1 1 1],...
	'callback',[
		'max2=str2num(get(sl2_max,''string''));',...  %read in the new value that the user has typed
		'set(sl2,''Max'',max2);',...
		'max_vector(2,input_fit)=max2;']);  %set the variable 'Max' related to slider object sl1 to the value of fart

%
% Change the minimum limit of the slider using edit-able text option
%

sl2_min=uicontrol(w1,...
	'style','edit',...
	'position',[25 65 35 15],...
	'string',num2str(min2),...		%get the current vale of the variable
	'foregroundcolor',[0 0 0],...
	'backgroundcolor',[1 1 1],...
	'callback',[
		'min2=str2num(get(sl2_min,''string''));',...  %read in the new value that the user has typed
		'set(sl2,''Min'',min2);',...
		'min_vector(2,input_fit)=min2;']);  %set the variable 'max' related to slider object sl1 to the value of fart


sl3_value=curr_vector(3,input_fit);
max3=max_vector(3,input_fit);
min3=min_vector(3,input_fit);

sl3=uicontrol(w1,...
	'style','slider',...
	'position',[65 20 70 15],...
	'BackgroundColor',[0.75 0.75 0.75],...
	'Min',min3,...
	'Max',max3,...
	'Value',sl3_value,...
	'CallBack',[
		'sl3_value=(get(sl3,''Value''));',...
		'set(text15,''string'',num2str(get(sl3,''Value'')));',...
		'if input_fit==1;',...
			'set_param(''midenmdl/Transport Delay1'',''Delay Time'', get(sl3,''Value''));',...
		'elseif input_fit==2;',...
			'set_param(''midenmdl/Transport Delay2'',''Delay Time'', get(sl3,''Value''));',...
		'elseif input_fit==3;',...
			'set_param(''midenmdl/Transport Delay3'',''Delay Time'', get(sl3,''Value''));',...
		'elseif input_fit==4;',...
			'set_param(''midenmdl/Transport Delay4'',''Delay Time'', get(sl3,''Value''));',...
		'elseif input_fit==5;',...
			'set_param(''midenmdl/Transport Delay5'',''Delay Time'', get(sl3,''Value''));',...
		'elseif input_fit==6;',...
			'set_param(''midenmdl/Transport Delay6'',''Delay Time'', get(sl3,''Value''));',...
		'elseif input_fit==7;',...
			'set_param(''midenmdl/Transport Delay7'',''Delay Time'', get(sl3,''Value''));',...
		'elseif input_fit==8;',...
			'set_param(''midenmdl/Transport Delay8'',''Delay Time'', get(sl3,''Value''));',...
		'elseif input_fit==9;',...
			'set_param(''midenmdl/Transport Delay9'',''Delay Time'', get(sl3,''Value''));',...
		'end;',...
			'curr_vector(3,input_fit)=sl3_value;',...
		'drawnow;']);

text14=da_text(w1,50,35,50,15,'Lp =',[0 0 0],[1 1 1]);
text15=uicontrol(w1,...

⌨️ 快捷键说明

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