wolffd@0: function [xvals, yvals, color] = hintmat(w); wolffd@0: %HINTMAT Evaluates the coordinates of the patches for a Hinton diagram. wolffd@0: % wolffd@0: % Description wolffd@0: % [xvals, yvals, color] = hintmat(w) wolffd@0: % takes a matrix W and returns coordinates XVALS, YVALS for the wolffd@0: % patches comrising the Hinton diagram, together with a vector COLOR wolffd@0: % labelling the color (black or white) of the corresponding elements wolffd@0: % according to their sign. wolffd@0: % wolffd@0: % See also wolffd@0: % HINTON wolffd@0: % wolffd@0: wolffd@0: % Copyright (c) Ian T Nabney (1996-2001) wolffd@0: wolffd@0: % Set scale to be up to 0.9 of maximum absolute weight value, where scale wolffd@0: % defined so that area of box proportional to weight value. wolffd@0: wolffd@0: w = flipud(w); wolffd@0: [nrows, ncols] = size(w); wolffd@0: wolffd@0: scale = 0.45*sqrt(abs(w)/max(max(abs(w)))); wolffd@0: scale = scale(:); wolffd@0: color = 0.5*(sign(w(:)) + 3); wolffd@0: wolffd@0: delx = 1; wolffd@0: dely = 1; wolffd@0: [X, Y] = meshgrid(0.5*delx:delx:(ncols-0.5*delx), 0.5*dely:dely:(nrows-0.5*dely)); wolffd@0: wolffd@0: % Now convert from matrix format to column vector format, and then duplicate wolffd@0: % columns with appropriate offsets determined by normalized weight magnitudes. wolffd@0: wolffd@0: xtemp = X(:); wolffd@0: ytemp = Y(:); wolffd@0: wolffd@0: xvals = [xtemp-delx*scale, xtemp+delx*scale, ... wolffd@0: xtemp+delx*scale, xtemp-delx*scale]; wolffd@0: yvals = [ytemp-dely*scale, ytemp-dely*scale, ... wolffd@0: ytemp+dely*scale, ytemp+dely*scale]; wolffd@0: