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

📄 demo1.m

📁 详细介绍了Mathlab的使用方法与技巧
💻 M
字号:
%**********************
%求系统在状态反馈前后的状态变化曲线Xk(t)Xb(t)
wind_demo10=figure('color',[1,1,1],'position',[0.1*winw,0.1*winh,0.8*winw,0.8*winh],...
       'name','习题演示窗口1:求系统在状态反馈前后的状态变化曲线Xk(t),Xb(t)','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.1,0.86,0.25,0.04];
showtext(pos,color,'输入系统状态空间:');
color=[.8;.8;0.8];
uicontrol('style','frame','position',[0.095,0.6,.7,.25],...
   'units','normalized','backgroundcolor',color);
pos=[0.1,0.78,0.04,0.04];
showtext(pos,color,'A:');
demo_edita=uicontrol(wind_demo10,'style','edit','pos',[0.15,0.78,0.62,0.04],...
        'string','[]','back',[0,0.7,1],'units','normalized');
pos=[0.1,0.73,0.04,0.04];
showtext(pos,color,'B:');
demo_editb=uicontrol(wind_demo10,'style','edit','pos',[0.15,0.73,0.62,0.04],...
        'string','[]','back',[0,0.7,1],'units','normalized');
pos=[0.1,0.68,0.04,0.04];
showtext(pos,color,'C:');
demo_editc=uicontrol(wind_demo10,'style','edit','pos',[0.15,0.68,0.62,0.04],...
        'string','[]','back',[0,0.7,1],'units','normalized');
pos=[0.1,0.63,0.04,0.04];
showtext(pos,color,'D:');
demo_editd=uicontrol(wind_demo10,'style','edit','pos',[0.15,0.63,0.62,0.04],...
        'string','[0]','back',[0,0.7,1],'units','normalized');
%*************
color=[.9;.9;0.9];
pos=[0.1,0.52,0.25,0.04];
showtext(pos,color,'系统的原极点为:');
color=[.8;.8;0.8];
uicontrol('style','frame','position',[0.095,0.45,.7,.06],...
   'units','normalized','backgroundcolor',color);
pos=[0.1,0.46,0.04,0.04];
showtext(pos,color,'P:');
%*************
color=[.9;.9;0.9];
pos=[0.1,0.36,0.25,0.04];
showtext(pos,color,'系统希望极点为:');
color=[.8;.8;0.8];
uicontrol('style','frame','position',[0.095,0.29,.7,.06],...
   'units','normalized','backgroundcolor',color);
pos=[0.1,0.3,0.04,0.04];
showtext(pos,color,'P:');
demo_editp=uicontrol(wind_demo10,'style','edit','pos',[0.15,0.3,0.62,0.04],...
        'string','[]','back',[0,0.7,1],'units','normalized');
%***************
str3=['demop=eval(get(demo_editp,''string''));',...
      'kk=place(demoa,demob,demop);',...
      'at=demoa-demob*kk;bt=demob;ct=democ;dt=demod;',...
      't=[0:0.01:10];',...
      'subplot(1,2,2);',...
      '[y,x]=step(at,bt,ct,dt,1,t);',...
      'plot(t,y,t,x);',...
      'grid;ylabel(''Y(t)和X(t)'');title(''系统反馈后Xk(t)'');']

str2=['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'');',...
      'subplot(1,2,1);',...
      '[y,x]=step(demoa,demob,democ,demod,1,t);',...
      'plot(t,y,t,x);',...
      'grid;ylabel(''Y(t)和X(t'');title(''系统反馈前Xb(t)'');',...
      'demo10_3=uicontrol(windstep1,''style'',''push'',''string'',''求Xk(t)'',',...
      '                   ''position'',[0.3,0.05,0.15,0.06],''units'',''normalized'',''enable'',''on'',',...
      '                   ''callback'',str3);',...
      'uicontrol(windstep1,''style'',''push'',''string'',''Close'',',...
      '            ''position'',[0.59,0.05,0.15,0.06],''units'',''normalized'',',...
      '            ''callback'',''close(windstep1)'');']

str1=['set(demo10_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''));',...
      '[z,p,k]=ss2zp(demoa,demob,democ,demod,1);',...
      'pos=[0.15,0.46,.62,.04];showtext(pos,color,mat2str(p));']
demo10_2=uicontrol(wind_demo10,'style','push','string','求Xb(t)',...
       'position',[0.83,0.5,0.15,0.06],'units','normalized','enable','off',...
      'callback',str2);
udemo10_1=uicontrol(wind_demo10,'style','push','string','原极点P',...
       'position',[0.83,0.8,0.15,0.06],'units','normalized',...
      'callback',str1);
uicontrol(wind_demo10,'style','push','string','Close',...
       'position',[0.83,0.2,0.15,0.06],'units','normalized',...
      'callback','close(wind_demo10)');

⌨️ 快捷键说明

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