📄 ann.m
字号:
%delete(f_1);
global rnum hnum onum
set(f_1,'visible','off');
%set(m_1ctrlt,'visible','off');
set(gcf,'defaultuicontrolunits','normalized');
H=axes('unit','normalized','position',[0,0,1,1],'visible','off');
%全局设置
top=0.98;
bottom=0.1;
left=0.01;
right=0.95;
textHeight = 0.03;
textWidth = 0.12;
labelWidth= 0.13;
radioWidth=0.25;
spacing=0.02;
%ga 参数
labelBottom=top-textHeight-spacing;
labelLeft = left+0.05;
frmPos=[left+0.03 labelBottom-4*textHeight-5*spacing 0.29 5*textHeight+6*spacing];
f_2=uicontrol('style','frame','position',frmPos,'background',[0.3 0.3 0.3],'foreground','Yellow');
labelPos = [labelLeft labelBottom labelWidth textHeight];
t_1 = uicontrol( ...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','变异概率', ...
'Interruptible','off', ...
'BackgroundColor',[0.3 0.3 0.3], ...
'ForegroundColor','white',...
'TooltipString','Sampling Frequency');
%text(0.1,0.95,'变异概率:','fontsize',10);
textPos = [labelLeft+labelWidth labelBottom textWidth textHeight];
e_pmutation= uicontrol( ...
'Style','edit', ...
'Units','normalized', ...
'Position',textPos, ...
'Horiz','center', ...
'Background','white', ...
'Foreground','black', ...
'String','0.015','Userdata',0.015);
labelBottom=top-2*textHeight-2*spacing;
labelPos = [labelLeft labelBottom labelWidth textHeight];
t_2 = uicontrol( ...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','交叉概率', ...
'Interruptible','off', ...
'BackgroundColor',[0.3 0.3 0.3], ...
'ForegroundColor','white');
%text(0.1,0.85,'交叉概率:','fontsize',10);
textPos = [labelLeft+labelWidth labelBottom textWidth textHeight];
e_pcross=uicontrol( ...
'Style','edit', ...
'Units','normalized', ...
'Position',textPos, ...
'Horiz','center', ...
'Background','white', ...
'Foreground','black', ...
'String','0.1','Userdata',0.1);
%uicontrol(gcf,'style','edit','background','white',...
% 'position',[0.25,0.825,0.15,0.05],'string','0.1');
labelBottom=top-3*textHeight-3*spacing;
labelPos = [labelLeft labelBottom labelWidth textHeight];
t_3 = uicontrol( ...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','最大世代数', ...
'Interruptible','off', ...
'BackgroundColor',[0.3 0.3 0.3], ...
'ForegroundColor','white');
%text(0.1,0.75,'最大世代数:','fontsize',10);
textPos = [labelLeft+labelWidth labelBottom textWidth textHeight];
e_maxgen=uicontrol( ...
'Style','edit', ...
'Units','normalized', ...
'Position',textPos, ...
'Horiz','center', ...
'Background','white', ...
'Foreground','black', ...
'String','50','Userdata',50);
%uicontrol(gcf,'style','edit','background','white',...
% 'position',[0.25,0.725,0.15,0.05],'string','50');
labelBottom=top-4*textHeight-4*spacing;
labelPos = [labelLeft labelBottom labelWidth textHeight];
t_4 = uicontrol( ...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','染色体长度', ...
'Interruptible','off', ...
'BackgroundColor',[0.3 0.3 0.3], ...
'ForegroundColor','white');
%text(0.1,0.65,'染色体长度:','fontsize',10);
textPos = [labelLeft+labelWidth labelBottom textWidth textHeight];
e_lchrom=uicontrol( ...
'Style','edit', ...
'Units','normalized', ...
'Position',textPos, ...
'Horiz','center', ...
'Background','white', ...
'Foreground','black', ...
'String','8','Userdata',8);
%uicontrol(gcf,'style','edit','background','white',...
% 'position',[0.25,0.625,0.15,0.05],'string','8');
labelBottom=top-5*textHeight-5*spacing;
labelPos = [labelLeft labelBottom labelWidth textHeight];
t_5 = uicontrol( ...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','种群大小', ...
'Interruptible','off', ...
'BackgroundColor',[0.3 0.3 0.3], ...
'ForegroundColor','white');
%text(0.1,0.55,'种群大小:','fontsize',10);
textPos = [labelLeft+labelWidth labelBottom textWidth textHeight];
e_popsize=uicontrol( ...
'Style','edit', ...
'Units','normalized', ...
'Position',textPos, ...
'Horiz','center', ...
'Background','white', ...
'Foreground','black', ...
'String','20','Userdata',20);
%结构选择
str_tann='gapidann';
rnum=2;hnum=3;onum=1;
t_6 = uicontrol( ...
'Style','text','FontSize',20,...
'Units','normalized', ...
'Position',[0.5 0.93 0.2 0.05], ...
'String','神经网络结构图', ...
'Interruptible','off', ...
'BackgroundColor','black', ...
'ForegroundColor','white');
t_7 = uicontrol( ...
'Style','text','FontSize',20,...
'Units','normalized', ...
'Position',[0.5 0.48 0.2 0.05], ...
'String','控制系统结构图', ...
'Interruptible','off', ...
'BackgroundColor','black', ...
'ForegroundColor','white');
icmann=imread('sys.jpg');
h2=axes('position',[0.4 0.2 0.4 0.25]);
im_sys=image(icmann);
set(h2,'visible','off');
ipidann=imread('pidann.jpg');
h=axes('position',[0.4 0.6 0.4 0.3]);
im_ann=image(ipidann);
set(h,'visible','off');
labelBottom=top-6*textHeight-8*spacing;
labelPos = [labelLeft labelBottom radioWidth textHeight];
frmPos=[left+0.03 labelBottom-2*textHeight-3*spacing 0.29 3*textHeight+4*spacing];
f_3=uicontrol('style','frame','position',frmPos,'background',[0.3 0.3 0.3],'foreground','Yellow');
r_oppidann=uicontrol(gcf,'style','radio','string','PID神经网络权值优化 ','position',labelPos);
set(r_oppidann,'value',get(r_oppidann,'Max'));
set(r_oppidann,'callback',[...
'set(r_oppidann,''value'',get(r_oppidann,''Max'')),',...
'set(r_opbpann,''value'',get(r_opbpann,''Min'')),',...
'set(r_opcmann,''value'',get(r_opcmann,''Min'')),',...
'str_tann=''gapidann'';',...
'rnum=2;hnum=3;onum=1;',...
'ipidann=imread(''pidann.jpg'');',...
'h=axes(''position'',[0.4 0.6 0.4 0.3]);',...
'delete(im_ann);',...
'im_ann=image(ipidann);',...
'set(h,''visible'',''off'');',...
]);
labelBottom=top-7*textHeight-9*spacing;
labelPos = [labelLeft labelBottom radioWidth textHeight];
r_opbpann=uicontrol(gcf,'style','radio','string','BP神经网络权值优化','position',labelPos);
set(r_opbpann,'callback',[...
'set(r_oppidann,''value'',get(r_oppidann,''Min'')),',...
'set(r_opbpann,''value'',get(r_opbpann,''Max'')),',...
'set(r_opcmann,''value'',get(r_opcmann,''Min'')),',...
'set(e_lchrom,''enable'',''on''),',...
'str_tann=''gabpann'';',...
'rnum=2;hnum=6;onum=1;',...
'ibpdann=imread(''bpann.jpg'');',...
'h=axes(''position'',[0.4 0.6 0.4 0.32]);',...
'delete(im_ann);',...
'im_ann=image(ibpdann);',...
'set(h,''visible'',''off'');',...
]);
labelBottom=top-8*textHeight-10*spacing;
labelPos = [labelLeft labelBottom radioWidth textHeight];
r_opcmann=uicontrol(gcf,'style','radio','string','小脑神经网络权值优化','position',labelPos);
set(r_opcmann,'callback',[...
'set(r_oppidann,''value'',get(r_oppidann,''Min'')),',...
'set(r_opbpann,''value'',get(r_opbpann,''Min'')),',...
'set(r_opcmann,''value'',get(r_opcmann,''Max'')),',...
'set(e_lchrom,''enable'',''on''),',...
'str_tann=''gacmann'';',...
'ibpdann=imread(''camc.jpg'');',...
'h=axes(''position'',[0.4 0.55 0.4 0.35]);',...
'delete(im_ann);',...
'im_ann=image(ibpdann);',...
'set(h,''visible'',''off'');',...
]);
%对象参数
%text(0.6,0.86,'对象级别:','fontsize',10);
labelBottom=top-9*textHeight-13*spacing;
frmPos=[left+0.03 labelBottom-6*textHeight-6*spacing 0.29 7*textHeight+7*spacing];
f_4=uicontrol('style','frame','position',frmPos,'background',[0.3 0.3 0.3],'foreground','Yellow');
labelPos = [labelLeft labelBottom radioWidth textHeight];
r_order1=uicontrol(gcf,'style','radio','string','一阶系统 ',...
'position',labelPos);
set(r_order1,'value',get(r_order1,'Max'));
order=1;differ='yout(tt)=-den(2)*y_1+num(2)*u_1;';
set(r_order1,'callback',['order=1;',...
'differ=''yout(tt)=-den(2)*y_1+num(2)*u_1;'';',...
'set(r_order1,''value'',get(r_order1,''Max'')),',...
'set(r_order2,''value'',get(r_order2,''Min'')),',...
'set(r_order3,''value'',get(r_order3,''Min'')),',...
'set(e_gs,''string'',''[0 1],[1 -1]''),',...
]);
labelBottom=top-10*textHeight-14*spacing;
labelPos = [labelLeft labelBottom radioWidth textHeight];
r_order2=uicontrol(gcf,'style','radio','string','二阶系统 ',...
'position',labelPos);
set(r_order2,'callback',[...
'differ=''yout(tt)=-den(2)*y_1-den(3)*y_2+num(2)*u_1+num(3)*u_2;'';',...
'order=2;set(r_order2,''value'',get(r_order2,''Max'')),',...
'set(r_order1,''value'',get(r_order1,''Min'')),',...
'set(r_order3,''value'',get(r_order3,''Min'')),',...
'set(e_gs,''string'',''[0 0 400],[1 50 0]''),',...
]);
labelBottom=top-11*textHeight-15*spacing;
labelPos = [labelLeft labelBottom radioWidth textHeight];
r_order3=uicontrol(gcf,'style','radio','string','三阶系统 ',...
'position',labelPos);
set(r_order3,'callback',[...
'differ=''yout(tt)=-den(2)*y_1-den(3)*y_2-den(4)*y_3+num(2)*u_1+num(3)*u_2+num(4)*u_3;'';',...
'order=3;set(r_order3,''value'',get(r_order3,''Max'')),',...
'set(r_order1,''value'',get(r_order1,''Min'')),',...
'set(r_order2,''value'',get(r_order2,''Min'')),',...
'set(e_gs,''string'',''[0 5 25 30],[1 6 10 8]''),',...
]);
labelBottom=top-12*textHeight-16*spacing;
labelPos = [labelLeft labelBottom labelWidth textHeight];
t_9 = uicontrol( ...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','对象传递函数', ...
'Interruptible','off', ...
'BackgroundColor',[0.3 0.3 0.3], ...
'ForegroundColor','white');
%text(0.6,0.7,'对象传递函数:','fontsize',10);
textPos = [labelLeft+labelWidth labelBottom textWidth textHeight];
e_gs=uicontrol( ...
'Style','edit', ...
'Units','normalized', ...
'Position',textPos, ...
'Horiz','center', ...
'Background','white', ...
'Foreground','black', ...
'String','[0 1],[1 -1]');
%e_gs=uicontrol(gcf,'style','edit','background','white',...
% 'position',[0.78,0.675,0.15,0.05],'string','1,[1 -1]');
labelBottom=top-14*textHeight-17*spacing;
labelPos = [labelLeft labelBottom 0.25 2*textHeight];
t_11 = uicontrol(...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos, ...
'Horiz','left', ...
'String',char(' 注:若对象传递函数为(a*s^2+b*s+c)/(d*s^2+e*s+f)',' 则输入[a b c],[d e f]'), ...
'Interruptible','off', ...
'BackgroundColor',[0.3 0.3 0.3], ...
'ForegroundColor','white');
labelBottom=top-15*textHeight-18*spacing;
labelPos = [labelLeft labelBottom labelWidth textHeight];
t_10 = uicontrol( ...
'Style','text', ...
'Units','normalized', ...
'Position',labelPos, ...
'Horiz','left', ...
'String','采样周期(s)', ...
'Interruptible','off', ...
'BackgroundColor',[0.3 0.3 0.3], ...
'ForegroundColor','white');
%text(0.6,0.6,'采样周期(s):','fontsize',10);
textPos = [labelLeft+labelWidth labelBottom textWidth textHeight];
e_ts=uicontrol( ...
'Style','edit', ...
'Units','normalized', ...
'Position',textPos, ...
'Horiz','center', ...
'Background','white', ...
'Foreground','black', ...
'String','0.001');
%e_ts=uicontrol(gcf,'style','edit','background','white',...
% 'position',[0.78,0.575,0.15,0.05],'string','0.001');
b_1ok=uicontrol(gcf,'style','push','unit','normalized',...
'position',[0.4,0.04,0.1,0.05],'string','确定参数');
set(b_1ok,'callback',[...
'pmutate=str2num(get(e_pmutation,''string''));',...
'pcross=str2num(get(e_pcross,''string''));',...
'maxgen=str2num(get(e_maxgen,''string''));',...
'lchrom=str2num(get(e_lchrom,''string''));',...
'popsize=str2num(get(e_popsize,''string''));',...
'ts=str2num(get(e_ts,''string''));',...
'z=str2num(get(e_gs,''string''));',...
'gs=tf(z(1:order+1),[z(order+2:end)]);',...
'delete(b_1ok,e_gs,e_ts,r_order1,r_order2,r_order3);',...
'delete(e_pmutation,e_pcross,e_maxgen,e_lchrom,e_popsize);',...
'delete(t_1,t_2,t_3,t_4,t_5,t_6,t_7,t_9,t_10,t_11,f_2,f_3,f_4);'...
'delete(r_oppidann,r_opbpann,r_opcmann,gca);',...
'eval(str_tann)',...
]);
b_2back=uicontrol(gcf,'style','push','unit','normalized',...
'position',[0.55,0.04,0.1,0.05],'string','返回');
set(b_2back,'callback','gaop');
set(b_2back,'background','green');
set(b_1ok,'background','green');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -