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

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

[k,v] = seccoefficients(h);

% Handle the scalar case
if length(k)==1 & length(v) == 1 & k == 0,
    a = []; b = []; c = []; d = v;
    return
end

% Form a single-section allpass object with k
f = latcallpass(k);

% Get state-space of allpass, a and b are the same
[a,b,ct,dt] = sec2ss(f);
% Make sure v is a column
v = v(:);

% Concatenate a and c; b and d
at = [a;ct];
bt = [b;dt];

% Multiply each row of at by v(n) and sum up the columns to get c
c = sum(at.*v(:,ones(size(at,2),1)));

% Multiply each row of bt by v(n) and sum up to get d
d = sum(bt.*v(:,ones(size(bt,2),1)));

