Пакет MatLab. Элементы программирования. Функции пакета. Графические возможности пакета, страница 19

'Units','normalized','BackgroundColor','black',...

'ForegroundColor','white','String',num2str(p(1)));

p2_t=uicontrol('style','text','pos',[ip0 jp0-.04 ips jps],...

'Units','normalized','BackgroundColor','black',...

'ForegroundColor','white','String',num2str(p(2)));

ip0=.32; jp0=.13; ips=.31; jps=.03;

uicontrol('style','text','pos',[ip0 jp0 ips jps],...

'Units','normalized','BackgroundColor','black',...

'ForegroundColor','yellow','String','dx1/dt =                     x2');

uicontrol('style','text','pos',[ip0 jp0-.04 ips jps],...

'Units','normalized','BackgroundColor','black',...

'ForegroundColor','yellow','String','dx2/dt = - a2*x1 - a1*x2');

ie0=.41; je0=.21; ies=.05; jes=.03;

a1_ed=uicontrol('Style','edit','Position',[ie0 je0 ies jes],...

'Units','normalized','String',num2str(a1),...

'BackgroundColor','black','ForegroundColor','white',...

'CallBack','lab2(''seta1'',2); lab2(''redraw'');');

a2_ed=uicontrol('Style','edit','Position',[ie0 je0+.07 ies jes],...

'Units','normalized','String',num2str(a2),...

'BackgroundColor','black','ForegroundColor','white',...

'CallBack','lab2(''seta2'',2); lab2(''redraw'');');

x1_ed=uicontrol('Style','edit','Position',[ie0+.2 je0+.2 ies+.01 jes],...

'Units','normalized','String',num2str(x0(1)),...

'BackgroundColor','black','ForegroundColor','white',...

'CallBack','lab2(''setx1'',2); lab2(''redraw'');');

x2_ed=uicontrol('Style','edit','Position',[ie0+.07 je0+.2 ies+.01 jes],...

'Units','normalized','String',num2str(x0(2)),...

'BackgroundColor','black','ForegroundColor','white',...

'CallBack','lab2(''setx2'',2); lab2(''redraw'');');

x_pp=axes('Position',[.04 .53 .53 .44],'XLim',[0 Tk],'YLim',[-xm xm]);

pp_line=plot(t,x,'EraseMode','xor'); grid;

axis([0 Tk -xm xm]); %xlabel('Time (Seconds)');

xfp=axes('Position',[.64 .53 .32 .44],'XLim',[-xm xm],'YLim',[-xm xm]);

fp_line=plot(x(:,1),x(:,2),'EraseMode','xor'); grid;

axis([-xm xm -xm xm]);  axis('square'); ylabel('x2');  xlabel('x1');

rootp=axes('Position',[.74 .18 .21 .26],'XLim',[-mm mm],'YLim',[-mm mm]);

ro_line=plot(rp,ip,'*','EraseMode','xor'); grid;

axis([-mm mm -mm mm]);  ylabel('Im');  xlabel('Re');

drawnow;

LAB2_D=[    a1; a1_sl; min_a1; max_a1;    a2; a2_sl; min_a2;  max_a2;...

x0(1);    x1_sl;    min_x1;               max_x1;x0(2);   x2_sl;    min_x2;               max_x2;...

a1_ed;   a2_ed;   x1_ed;   x2_ed;   b;           dt;          Tk;         pp_line;...

fp_line; ro_line; p1_t;      p2_t];

elseif strcmp(action,'seta1'),

if(in1==1)  LAB2_D(1)=get(LAB2_D(2),'value');

else min_a1=LAB2_D(3);  max_a1=LAB2_D(4);

a1=str2num(get(LAB2_D(17),'string'));

if (a1>=max_a1),  a1=max_a1;  end;

if (a1<=min_a1),  a1=min_a1;  end;

LAB2_D(1)=a1;    end

elseif strcmp(action,'seta2'),

if(in1==1)  LAB2_D(5)=get(LAB2_D(6),'value');

else min_a2=LAB2_D(7);  max_a2=LAB2_D(8);

a2=str2num(get(LAB2_D(18),'string'));

if (a2>=max_a2),  a2=max_a2;  end;

if (a2<=min_a2),  a2=min_a2;  end;

LAB2_D(5)=a2;    end

elseif strcmp(action,'setx1'),

if(in1==1)  LAB2_D(9)=get(LAB2_D(10),'value');

else min_x1=LAB2_D(11);  max_x1=LAB2_D(12);

x0(1)=str2num(get(LAB2_D(19),'string'));

if (x0(1)>=max_x1),  x0(1)=max_x1;  end;

if (x0(1)<=min_x1),  x0(1)=min_x1;  end;

LAB2_D(9)=x0(1);    end

elseif strcmp(action,'setx2'),

if(in1==1)  LAB2_D(13)=get(LAB2_D(14),'value');

else min_x2=LAB2_D(15);  max_x2=LAB2_D(16);

x0(2)=str2num(get(LAB2_D(20),'string'));

if (x0(2)>=max_x2),  x0(2)=max_x2;  end;

if (x0(2)<=min_x2),  x0(2)=min_x2;  end;

LAB2_D(13)=x0(2);   end

elseif strcmp(action,'redraw'),

a1=LAB2_D(1); set(LAB2_D( 2),'value',a1); set(LAB2_D(17),'string',num2str(a1));

a2=LAB2_D(5); set(LAB2_D( 6),'value',a2); set(LAB2_D(18),'string',num2str(a2));

x0(1)=LAB2_D( 9); set(LAB2_D(10),'value',x0(1));

set(LAB2_D(19),'string',num2str(x0(1)));

x0(2)=LAB2_D(13); set(LAB2_D(14),'value',x0(2));

set(LAB2_D(20),'string',num2str(x0(2)));

b=LAB2_D(21); dt=LAB2_D(22); Tk=LAB2_D(23);

A=[0 1; -a2 -a1]; B=[0; b]; C=[1 0]; D=0; t=0:dt:Tk; u=ones(1,Tk/dt+1);

[y,x]=lsim(A,B,C,D,u,t,x0);   p=eig(A); ip=imag(p); rp=real(p);

mi=max(ip); if(abs(min(ip))>mi) mi=abs(min(ip)); end