function [ZVe,NVe,Q,IN,OU,MT,NV,BRF]=struc020(SOR,OU,P1,P2)
%        [ZVe,NVe,Q,IN,OU,MT,NV,BRF]=struc020(SOR,OU,P1,P2)
%STRUC020 T(bran): Par=[Tel TM TF TL];
%                  Reg=[Kd Km Kn];
%         State control structure: reference Brandenburg at 35(1987)7, pp.275/83
%	      structure and simulation see SIST020.mdl; hint: KL=-(1+Km)

%AUXILIARY FILE for symbolical definition - no stand-alone calling !!!
%	  SOR:   switch - to shift between plant or control structure
%	  OU:    vector using continuous output numbers for discretized plant state
%            description
%     P1,P2: posibility of any parameter transfer via bod_es.m

% KEY WORDS: Digital Magnitude Optimum, symbolical plant and control structure
%            definition, application basis for: bod_es. / bod_esg.m / bod_esp.m

% Copyright (c) 2011-2023 Dr. Gert-Helge Geitner, TU Dresden,
%                     https://wwwpub.zih.tu-dresden.de/~geitner/ae_1_0e.htm
% Digital Magnitude Optimum reference: Geitner, G.-H.:
%                    Entwurf digitaler Regler für elektrische Antriebe.
%                    VDE-Verlag GmbH Berlin und Offenbach 1996
%                    ISBN 3-8007-1847-2

if SOR==0  %plant structure definition

% ****** beginning ******
 sz1='1;';			sn1='[Tel 1];';
 sz2='1;';			sn2='[TM 0];';
 sz3='1;';			sn3='1;';
 sz4='1;';			sn4='[TF 0];';
 sz5='1;';			sn5='[TL 0];';
 Q=[1 0  0
    2 1 -4
    3 2 -5
    4 3  0
    5 4  0]; IN=[1]; OU=[2 5 3 4];
 MT=[0 1
     0 1
     0 1
     0 1];
 NV=['Tel; TM; TF; TL; '];
% ****** ending ******

s=0; zae=0; ZVe=[]; NVe=[]; BRF=0;
while s==0 zae=zae+1;  eval(['ZVe=[ZVe sz' num2str(zae) '];'],'s=1;');
                       eval(['NVe=[NVe sn' num2str(zae) '];'],'s=1;'); end

else  %control structure definition

%******* beginning ******
 rz5='Kd;';              rn5='1;';
 rz6='Km;';              rn6='1;';
 rz7='Kn;';              rn7='1;';

QQ=[1 -5 -6 7
    2 -5 -6 7
    3 -5 -6 7
    4 -5 -6 7
    5  3  0 0
    6  4  0 0
    7 -1  0 0];
BME=[1 1
     7 7];
BMA=[4 4
     1 2];
 BM=[2 2
     1 1
     0 0];  BRF=2;
NV=['Kd; Km; Kn; '];
%****** ending ******

s=0; zae=length(OU); ZVe=[]; NVe=[];
while s==0 zae=zae+1;  eval(['ZVe=[ZVe rz' num2str(zae) '];'],'s=1;');
                       eval(['NVe=[NVe rn' num2str(zae) '];'],'s=1;'); end
Q=QQ;IN=BME;OU=BMA;MT=BM;
end
