function pmats(top,left,mat,width,places) % usage: % pmats(top,left,mat,width,places) % % print a matrix with ids on left and top % with width columns with places to right of decimal % options if width, places not given: 8.4 % required: % top: string of names separated with | (for example, 'col1|col2|col3') % if names are fewer than columns, blanks are used on the left side of the table % left: string of names separated with | (for example, 'row1|row2|row3') % if names are fewer than rows, blanks are used at the end of the table % set defaults if needed if nargin<5 places = 2; end if nargin<4 width = 8; end % find dimensions [rows,cols] = size(mat); % find terminators in top and left, pad as needed topend = findstr(top,'|'); if length(topend)<(cols+1) num = cols + 1 - length(topend); pad = setstr(ones(1,num)*abs('|')); top = [pad top]; end; leftend = findstr(left,'|'); if length(leftend)