Code covered by the BSD License  

Highlights from
DFiltFIR

image thumbnail
from DFiltFIR by Peter Kabal
Design linear-phase FIR filters - with upper/lower constraints and flexible specifications

PrMatrix (Banner, x)
function PrMatrix (Banner, x)
% Pretty print a matrix. For the most compact printout, transpose column
% vectors before calling this routine.
% PrMatrix (x):         Print x
% PrMatrix (Banner, x): Print x with a Banner

% $Id: PrMatrix.m,v 1.5 2009/06/05 15:48:51 pkabal Exp $

NVLINE = 5;	      % Number of values to a line 
NCSTAGGER = 2;	  % No. chars to stagger continuation lines
MAXSTAGGER = 10;	% Max. chars to stagger continuation lines

% Resolve the input parameters
if (nargin == 1)
  % PrMatrix (x)
  x = Banner;
  Banner = [];
end

if (~ isempty(Banner))
  fprintf('%s\n', Banner);
end

[Nrow, Ncol] = size(x);
blanks = repmat(' ', 1, MAXSTAGGER);
for (i = 0:Nrow-1)
  jl = 0;
  for (j = 0:Ncol-1)
    fprintf('%13.5g', x(i+1,j+1));
    if (j > 0 && j < Ncol - 1 && mod(j + 1, NVLINE) == 0)
      % Stagger continuation lines for a row
      jl = jl + 1;
      ns = mod(jl * NCSTAGGER, MAXSTAGGER);
      fprintf('\n');
      fprintf('%s', blanks(1:ns));
    end
  end
  fprintf('\n');
end

return

Contact us at files@mathworks.com