📄 demo7.m
字号:
%**********************
%用例子说明对不能控子系统进行状态反馈无效
wind_demo7=figure('color',[1,1,1],'position',[0.1*winw,0.1*winh,0.8*winw,0.8*winh],...
'name','习题演示窗口7:说明对系统哪个状态变量进行状态反馈无效','numbertitle','off','menubar','none',...
'resize','off','clipping','off');
color=[0.9;.9;.9];
uicontrol('style','frame','position',[0,0,1,1],...
'units','normalized','backgroundcolor',color);
pos=[0.08,0.94,0.32,0.04];
showtext(pos,color,'任意给出不可控子系统的状态空间:');
color=[.8;.8;0.8];
uicontrol('style','frame','position',[0.095,0.73,.7,.21],...
'units','normalized','backgroundcolor',color);
pos=[0.1,0.89,0.04,0.04];
showtext(pos,color,'A:');
demo_edita=uicontrol(wind_demo7,'style','edit','pos',[0.15,0.89,0.62,0.04],...
'string','[]','back',[0,0.7,1],'units','normalized');
pos=[0.1,0.84,0.04,0.04];
showtext(pos,color,'B:');
demo_editb=uicontrol(wind_demo7,'style','edit','pos',[0.15,0.84,0.62,0.04],...
'string','[]','back',[0,0.7,1],'units','normalized');
pos=[0.1,0.79,0.04,0.04];
showtext(pos,color,'C:');
demo_editc=uicontrol(wind_demo7,'style','edit','pos',[0.15,0.79,0.62,0.04],...
'string','[]','back',[0,0.7,1],'units','normalized');
pos=[0.1,0.74,0.04,0.04];
showtext(pos,color,'D:');
demo_editd=uicontrol(wind_demo7,'style','edit','pos',[0.15,0.74,0.62,0.04],...
'string','[0]','back',[0,0.7,1],'units','normalized');
%*************
color=[0.9,0.9,0.9];
pos=[0.08,0.68,0.3,0.04];
showtext(pos,color,'系统的对角型(约当型)状态空间:');
color=[.8;.8;0.8];
uicontrol('style','frame','position',[0.02,0.47,.78,.21],...
'units','normalized','backgroundcolor',color);
pos=[0.0251,0.63,0.02,0.04];
showtext(pos,color,'A:');
pos=[0.025,0.58,0.02,0.04];
showtext(pos,color,'B:');
pos=[0.025,0.53,0.02,0.04];
showtext(pos,color,'C:');
pos=[0.025,0.48,0.02,0.04];
showtext(pos,color,'D:');
%$$$$$$$$$$$$
color=[0.9,0.9,0.9];
pos=[0.08,0.4,0.25,0.04];
showtext(pos,color,'系统状态变量可控性分析:');
color=[.8;.8;0.8];
uicontrol('style','frame','position',[0.095,0.34,.7,.06],...
'units','normalized','backgroundcolor',color);
%*************
color=[.9;.9;0.9];
pos=[0.08,0.28,0.25,0.04];
showtext(pos,color,'任意给定状态反馈向量K:');
color=[.8;.8;0.8];
uicontrol('style','frame','position',[0.095,0.22,.7,.06],...
'units','normalized','backgroundcolor',color);
pos=[0.1,0.23,0.04,0.04];
showtext(pos,color,'K:');
demo_editk=uicontrol(wind_demo7,'style','edit','pos',[0.15,0.23,0.62,0.04],...
'string','[]','back',[0,0.7,1],'units','normalized');
%***************
color=[0.9,0.9,0.9];
pos=[0.08,0.16,0.22,0.04];
showtext(pos,color,'状态反馈后系统可控性:');
color=[.8;.8;0.8];
uicontrol('style','frame','position',[0.095,0.1,.7,.06],...
'units','normalized','backgroundcolor',color);
%***************
str1=['set(udemo7_2,''enable'',''on'');',...
'demoa=eval(get(demo_edita,''string''));demob=eval(get(demo_editb,''string''));',...
'democ=eval(get(demo_editc,''string''));demod=eval(get(demo_editd,''string''));',...
'co1=ctrb(demoa,demob);m1=rank(co1);[m,n]=size(demoa);',...
'[a1,b1,c1,d1,t1]=canon(demoa,demob,democ,demod,''model'');',...
'pos=[0.05,0.63,0.73,0.04];showtext(pos,color,mat2str(a1));',...
'pos=[0.05,0.58,0.737,0.04];showtext(pos,color,mat2str(b1));',...
'pos=[0.05,0.53,0.74,0.04];showtext(pos,color,mat2str(c1));',...
'pos=[0.05,0.48,0.74,0.04];showtext(pos,color,mat2str(d1));']
str2=['set(udemo7_3,''enable'',''on'');',...
'[m,n]=size(demoa);t=0;stru=[];',...
'for i=1:1:m',...
' if (abs(b1(i:i,1:1))<=1e-7),t=1;stru=[stru ''X'' mat2str2(i) '',''];end;',...
'end;',...
'if (t==0),pos=[0.12,0.35,0.65,0.04];showtext(pos,color,''所有状态变量可控'');',...
'else,stru=[stru ''这些状态变量不可控,设置相应K进行状态反馈校验''];pos=[0.11,0.35,0.67,0.04];showtext(pos,color,stru);end;']
str3=['set(udemo7_4,''enable'',''on'');',...
't=[0:0.01:10];',...
'windstep1=figure(''color'',[0,0,0],''position'',[0.1*winw,0.1*winh,0.8*winw,0.8*winh],',...
' ''name'',''系统反馈前Xb(t),后Xk(t)'',''numbertitle'',''off'',''menubar'',''none'',',...
' ''resize'',''off'');',...
'[yc xt1]=step(demoa,demob,democ,demod,1,t);',...
'u=eye(size(demoa));[m,n]=size(demoa);',...
'subplot(1,2,1);',...
'plot(t,xt1);',...
'grid;ylabel(''状态X'');title(''系统反馈前Xb(t)'');',...
'demo10_3=uicontrol(windstep1,''style'',''push'',''string'',''求Xk(t)'',',...
' ''position'',[0.3,0.03,0.15,0.06],''units'',''normalized'',''enable'',''on'',',...
' ''callback'',str4);',...
'uicontrol(windstep1,''style'',''push'',''string'',''Close'',',...
' ''position'',[0.59,0.03,0.15,0.06],''units'',''normalized'',',...
' ''callback'',''close(windstep1)'');']
str4=['demok=eval(get(demo_editk,''string''));',...
'at=demoa-demob*demok;bt=demob;ct=democ;dt=demod;',...
't=[0:0.01:10];',...
'[yc2 xt2]=step(at,bt,ct,dt,1,t);',...
'u=eye(size(at));[m,n]=size(at);',...
'subplot(1,2,2);',...
'plot(t,xt2);',...
'grid;ylabel(''状态X'');title(''系统反馈后Xk(t)'');']
str5=['co=ctrb(demoa,demob);',...
'rco=rank(co);[m,n]=size(demoa);',...
'if (rco==n),pos=[0.12,0.11,0.67,0.04];showtext(pos,color,''系统能控'');',...
' else,pos=[0.12,0.11,0.67,0.04];showtext(pos,color,''仍然不能控'');end;']
udemo7_1=uicontrol(wind_demo7,'style','push','string','求对角型',...
'position',[0.83,0.8,0.15,0.06],'units','normalized',...
'callback',str1);
udemo7_2=uicontrol(wind_demo7,'style','push','string','分析说明',...
'position',[0.83,0.65,0.15,0.06],'units','normalized','enable','off',...
'callback',str2);
udemo7_3=uicontrol(wind_demo7,'style','push','string','反馈校验',...
'position',[0.83,0.5,0.15,0.06],'units','normalized','enable','off',...
'callback',str3);
udemo7_4=uicontrol(wind_demo7,'style','push','string','可控性',...
'position',[0.83,0.35,0.15,0.06],'units','normalized','enable','off',...
'callback',str5);
uicontrol(wind_demo7,'style','push','string','Close',...
'position',[0.83,0.2,0.15,0.06],'units','normalized',...
'callback','close(wind_demo7)');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -