function [a,b,c,d] = sec2ss(h)
%SEC2SS  Convert latcallpass object to state-space.

%   Author(s): R. Losada
%   Copyright 1988-2000 The MathWorks, Inc.
%   $Revision: 1.2 $  $Date: 2000/06/13 21:21:53 $ 

k = seccoefficients(h);

% Make sure k is a row
k = k(:).';
% Record the length of k
N = length(k);
% Generate a upper triangular matrix of ones
lowtriag = triu(ones(N),-1);
% Multiply each row except the first by conj(k(1:end-1))
for n = 1:N-1,
    lowtriag(n+1,:) = k(n)'.*lowtriag(n+1,:);
end
% Multiply each column by k
ktemp = k(ones(size(lowtriag,2),1),:);
lowtriag = lowtriag.*ktemp;
% Form the matrices a, b, c and d
a = [zeros(1,N);eye(N-1) zeros(N-1,1)] - lowtriag;
b = [1;k(1:end-1)'];

c = [zeros(1,N-1) 1-k(end)'.*k(end)];

d = k(end)';


