Code covered by the BSD License  

Highlights from
Rsyso

image thumbnail

Rsyso

by

 

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

[G Ginf]=serialdtf(Gt)
function [G Ginf]=serialdtf(Gt)
% SERIALDTF Serial Descomposition of the Transfer Function
%
% Syntax:  [G Ginf] = serialdtf(Gt)
%
% Inputs:
%    SYS - LTI SISO system, in Transfer Function -TF
%    representation.  
%
% Outputs:
%    G     - Matrix with the simple transfer functions
%    Ginf  - Scalar when the transfer function is biproper Gt= G + Ginf
%
% Example: 
%   G1=tf([1 0],conv(conv([1 1],[1 1]),conv([1 2],[1 2])));
%
%   [G]=serialdtf(Gt)
%
% Other m-files required: 
% Subfunctions:          mtfsp
%                        cellround
% 
%
% Author: Franklin Pineda
% email: franklin.pineda@fuac.edu.co
% Created: March 2011; 
% Last revision: 11-March-2011;

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

%------------- BEGIN CODE --------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[z p g] = zpkdata(Gt);
if length(z{:})==length(p{:})
    [Gt Ginf]=mtfsp(Gt);
    [z p g] = zpkdata(Gt); 
else
    Ginf=0;
end
[z p]=cellround(z,p);
z=cell2mat(z);
p=cell2mat(p);
k=ones(length(p),1);
G(1)=zpk([],p(1),g);
i=2;
warning off all;
while i<=length(p)
    if i<=length(z)+1
        G(i)=zpk([z(i-1)],[p(i)],k(i));
        i=i+1;        
    else
        G(i)=zpk([],[p(i)],k(i));
        i=i+1;
    end
end
i=1;
while i<=length(G)
    if ~isreal(G(i))    
        G(i)=series(G(i),G(i+1));
        G(i+1)=[];       
    end
    i=i+1;
end

Contact us