Code covered by the BSD License  

Highlights from
MIMOtool

image thumbnail

MIMOtool

by

 

12 Nov 2001 (Updated )

Multi Input Multi Output Systems Toolbox

lqg0.m
function lqg0(n)
%LQG0 : funzione di creazione della finestra del controllo LQR
%
%  lqg0(n)
%
% n = intero che indica il numero di blocchi di integratori
%     richiesti nella finestra precedente
%
%Massimo Davini 26/05/99 --- revised 31/05/99


global stack;

set(findobj('tag','integratori'),'visible','off');
set(findobj('tag','EditIntegr'),'visible','off');
drawnow;

G=pck(stack.general.A,stack.general.B,stack.general.C,stack.general.D);
[ty,no,ni,ns]=minfo(G);

nm=min(no,ni);
P=G;
Ibs=pck(zeros(nm),eye(nm),eye(nm),zeros(nm));
if ni<no Ibi=Ibs;Ibo=eye(no); else Ibi=eye(ni);Ibo=Ibs; end;
for k=1:n P=mmult(Ibo,P,Ibi); end;

%in questo modo ho aggiunto gli n integratori richiesti in ingresso
%o in uscita a seconda di qual' il lato (righe o colonne) a 
%dimensione  minima in G.

[A,B1,B2,C1,C2,D11,D12,D21,D22]=hpar(P,[no,ni]);

Q=eye(size(A));   
R=eye(ni);
W=eye(size(A));  
V=eye(no);

stack.temp.Q=Q;
stack.temp.R=R;
stack.temp.W=W;
stack.temp.V=V;
stack.temp.flagQ=0;         %flag di memorizzazione di Q
stack.temp.flagR=0;         %flag di memorizzazione di R
stack.temp.flagW=0;         %flag di memorizzazione di W
stack.temp.flagV=0;         %flag di memorizzazione di V
stack.temp.integratori=n;   %blocchi di integratori aggiunti
stack.temp.plant=G;         %original plant
stack.temp.augmplant=P;     %augmented plant



lq(1)=uicontrol('style','frame','units','normalized',...
   'position',[0.035 0.835 0.11 0.11],'backgroundcolor',[1 1 1],...
   'Visible','off','tag','FQ');

lq(2)=uicontrol('style','frame','units','normalized',...
   'position',[0.165 0.835 0.11 0.11],'backgroundcolor',[1 1 1],...
   'Visible','off','tag','FR');

lq(3)=uicontrol('style','frame','units','normalized',...
   'position',[0.295 0.835 0.11 0.11],'backgroundcolor',[1 1 1],...
   'Visible','off','tag','FW');

lq(4)=uicontrol('style','frame','units','normalized',...
   'position',[0.425 0.835 0.11 0.11],'backgroundcolor',[1 1 1],...
   'Visible','off','tag','FV');

ist0='delete(findobj(''tag'',''inf''));';
ist1='set(findobj(''tag'',''FQ''),''visible'',''off'');';
ist2='set(findobj(''tag'',''FR''),''visible'',''off'');';
ist3='set(findobj(''tag'',''FW''),''visible'',''off'');';
ist4='set(findobj(''tag'',''FV''),''visible'',''off'');';
ist5='set(findobj(''tag'',''FQ''),''visible'',''on'');';
ist6='set(findobj(''tag'',''FR''),''visible'',''on'');';
ist7='set(findobj(''tag'',''FW''),''visible'',''on'');';
ist8='set(findobj(''tag'',''FV''),''visible'',''on'');';
ist9='set(findobj(''tag'',''BREG''),''visible'',''off'');';
ist10='set(findobj(''tag'',''BSAVE''),''visible'',''on'',''enable'',''on'');';

lq(5)=uicontrol('style','push','unit','normalized',...
   'fontunits','normalized','fontsize',.5,'fontweight','bold',...
   'Horizontalalignment','center','string','Q',...
   'position',[0.05 0.85 0.08 0.08],'tag','BQ',...
   'callback',[ist0,ist2,ist3,ist4,ist5,'setmatrix(stack.temp.Q,''Q'');',ist9,ist10]);

lq(6)=uicontrol('style','push','unit','normalized',...
   'fontunits','normalized','fontsize',.5,'fontweight','bold',...
   'Horizontalalignment','center','string','R',...
   'position',[0.18 0.85 0.08 0.08],'tag','BR',...
   'callback',[ist0,ist1,ist3,ist4,ist6,'setmatrix(stack.temp.R,''R'');',ist9,ist10]);

lq(7)=uicontrol('style','push','unit','normalized',...
   'fontunits','normalized','fontsize',.5,'fontweight','bold',...
   'Horizontalalignment','center','string','W',...
   'position',[0.31 0.85 0.08 0.08],'tag','BW',...
   'callback',[ist0,ist1,ist2,ist4,ist7,'setmatrix(stack.temp.W,''W'');',ist9,ist10]);

lq(8)=uicontrol('style','push','unit','normalized',...
   'fontunits','normalized','fontsize',.5,'fontweight','bold',...
   'Horizontalalignment','center','string','V',...
   'position',[0.44 0.85 0.08 0.08],'tag','BV',...
   'callback',[ist0,ist1,ist2,ist3,ist8,'setmatrix(stack.temp.V,''V'');',ist9,ist10]);

lq(9)=uicontrol('style','push','unit','normalized',...
   'fontunits','normalized','fontsize',.5,'fontweight','bold',...
   'Horizontalalignment','center','string','COMPUTE LQG',...
   'position',[0.57 0.85 0.38 0.08],...
   'callback','lqg1;','tag','BREG');

lq(10)=uicontrol('style','push','unit','normalized',...
   'fontunits','normalized','fontsize',.5,'fontweight','bold',...
   'Horizontalalignment','center','string','SAVE MATRIX',...
   'position',[0.57 0.85 0.38 0.08],'enable','off',...
   'callback','salvalqg;','tag','BSAVE');

campi=['''Q'',''R'',''W'',''V'',''flagQ'',''flagR'',''flagW'',''flagV'',''integratori'',''plant'',''augmplant'''];
lq(11)=uicontrol('style','push','unit','normalized','position',[0.05 0.05 0.14 0.12],...
   'fontunits','normalized','fontsize',.35,'fontweight','bold',...
   'string','BACK','Horizontalalignment','center','tag','BottBC',...
   'TooltipString','Back to the previous window','userdata',sprintf('feval(''back_syn'',''integratori'',%u,%s)',length(stack.temp.handles),campi),...
   'callback',sprintf('if stack.general.K_flag messag(gcf,''kns'',''back'');else back_syn(''integratori'',%u,%s);end;',length(stack.temp.handles),campi));
   
lq(12)=uicontrol('style','push','unit','normalized','position',[0.2 0.05 0.14 0.12],...
   'fontunits','normalized','fontsize',.35,'fontweight','bold',...
   'string','CLOSE','Horizontalalignment','center','userdata',sprintf('feval(''back_syn'',''syn0'',0,%s)',campi),...
   'TooltipString','Back to the main SYNTHESIS window','tag','BottBC',...
   'callback',sprintf('if stack.general.K_flag messag(gcf,''kns'',''close'');else back_syn(''syn0'',0,%s);end;',campi));
   
lq(13)=uicontrol('style','push','unit','normalized',...
   'fontunits','normalized','fontsize',.35,'fontweight','bold',...
   'TooltipString','Evaluate the computed Controller',...
   'Horizontalalignment','center','string','EVALUATION',...
   'position',[0.39 0.05 0.275 0.12],...
   'callback','valuta;','tag','BEVAL','enable','off');

lq(14)=uicontrol('style','push','unit','normalized',...
   'fontunits','normalized','fontsize',.35,'fontweight','bold',...
   'TooltipString','Open the SIMULINK Closed-Loop-System',...
   'Horizontalalignment','center','string','SIMULATION',...
   'position',[0.675 0.05 0.275 0.12],...
   'callback','simula;','tag','BSIMU','enable','off');

drawnow;

stack.temp.handles=[stack.temp.handles,lq];

Contact us