function str = privdispstr(nsec,strs,coeffs)
%PRIVDISPSTR  Form string of coefficients that is adequate for display.
%   This function is private to be called by DFILT objects.
%
%   Inputs:
%   nsec   - number of sections
%   strs   - cell of strings, contains the label for each vector or matrix
%   coeffs - cell array of coefficients (e.g. {{B1,A1},{B2,A2},...})

%   Author(s): R. Losada
%   Copyright 1988-2000 The MathWorks, Inc.
%   $Revision: 1.3 $  $Date: 2000/08/04 16:29:27 $ 


% Initialize the cell array
c = {};

for n = 1:nsec,
    
    if nsec > 1,
        % Add the string 'Section' before each section only when more than one section
        c = {c{:},'', ['Section ',sprintf('%d',n)],'----------'};
    end
    
    % Get the coefficients for a given section
    seccoeffs = coeffs{n};
    
    for nstrs = 1:length(strs),
        % Form a string for each input vector or matrix in varargin
        parcell = formpartialcell(strs{nstrs},seccoeffs{nstrs});       
        c = {c{:},parcell{:}};
    end          
end

str = char(c);


%----------------------------------------------------------------------
function partialcell = formpartialcell(labelstr,matrx)

[m,n] = size(matrx);

if m == 1
    % Vector is a row, make it a column vector
    matrx = matrx(:);
    m = length(matrx);
    n = 1; % Column
end

partialcell{1} = labelstr;

for i = 1:m,
    temprowstr = '';
    for j = 1:n,
        temprowstr = [temprowstr,num2str(matrx(i,j),'%20.15f')];
    end
    partialcell{i+1} = temprowstr;
end

    