diff toolboxes/FullBNT-1.0.7/netlab3.3/hintmat.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toolboxes/FullBNT-1.0.7/netlab3.3/hintmat.m	Tue Feb 10 15:05:51 2015 +0000
@@ -0,0 +1,41 @@
+function [xvals, yvals, color] = hintmat(w);
+%HINTMAT Evaluates the coordinates of the patches for a Hinton diagram.
+%
+%	Description
+%	[xvals, yvals, color] = hintmat(w)
+%	  takes a matrix W and returns coordinates XVALS, YVALS for the
+%	patches comrising the Hinton diagram, together with a vector COLOR
+%	labelling the color (black or white) of the corresponding elements
+%	according to their sign.
+%
+%	See also
+%	HINTON
+%
+
+%	Copyright (c) Ian T Nabney (1996-2001)
+
+% Set scale to be up to 0.9 of maximum absolute weight value, where scale
+% defined so that area of box proportional to weight value.
+
+w = flipud(w);
+[nrows, ncols] = size(w);
+
+scale = 0.45*sqrt(abs(w)/max(max(abs(w))));
+scale = scale(:);
+color = 0.5*(sign(w(:)) + 3);
+
+delx = 1;
+dely = 1;
+[X, Y] = meshgrid(0.5*delx:delx:(ncols-0.5*delx), 0.5*dely:dely:(nrows-0.5*dely));
+
+% Now convert from matrix format to column vector format, and then duplicate
+% columns with appropriate offsets determined by normalized weight magnitudes. 
+
+xtemp = X(:);
+ytemp = Y(:);
+
+xvals = [xtemp-delx*scale, xtemp+delx*scale, ...
+         xtemp+delx*scale, xtemp-delx*scale];
+yvals = [ytemp-dely*scale, ytemp-dely*scale, ...
+         ytemp+dely*scale, ytemp+dely*scale];
+