Code covered by the BSD License

# Rsyso

### Franklin Pineda (view profile)

Finds realizations of SISO linear systems. Autonoma of Colombia University.

[A B C D]=parallelform(Gt,val)
```function [A B C D]=parallelform(Gt,val)
% PARALLELFORM Finds the Parallel Realization of a LTI SISO SYS model.
%
% Syntax:  [A,B,C,D] = parallelform(Gt)
%
% Inputs:
%    SYS - LTI SISO system, in Transfer Function -TF
%    representation.
%    Option val:  '0' : Realization in parallel observable
%                 '1' : Realization in parallel controllable
%                 ' ' : Realization in parallel with controllable observable exchanges
% Outputs:
%    A -
%    B -
%    C -
%    D - space-state representation
%
% Example:
%   G1=tf([1 0],conv(conv([1 1],[1 1]),conv([1 2],[1 2])));
%
%   [A,B,C,D]=parallelform(Gt)
%
% Other m-files required:
% Subfunctions:             [a b c d]=tf2rform(G,n);
%                           [G D]=paralleldtf(Gt);
%
%
% Author: Franklin Pineda Torres
% email: franklin.pineda@fuac.edu.co
% Created: March 2011;
% Last revision: 23-March-2011;

% May be distributed freely for non-commercial use,
% but please leave the above info unchanged, for
% credit and feedback purposes

%------------- BEGIN CODE --------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[G D]=paralleldtf(Gt);
n=length(nargin);
if n==1 %exchanges
j=1;
for i=1:length(G),
if mod(i,2)==1
[a b c]=tf2rform(G(i),4);
else
[a b c]=tf2rform(G(i),8);
end
la=length(a);
A(j:j+la-1,j:j+la-1)=a;
B(j:j+la-1,1)=b;
C(1,j:la+j-1)=c;
j=i+la;
end
elseif n==2
switch val
case val==0
[A B C]=coform(G,4);%observable
case val==1
[A B C]=coform(G,8);%controllable
end
end

function [A B C]=coform(G,val)
j=1;
for i=1:length(G),
[a b c]=tf2rform(G(i),val);
la=length(a);
A(j:j+la-1,j:j+la-1)=a;
B(j:j+la-1,1)=b;
C(1,j:la+j-1)=c;
j=i+la;
end
```