annotate toolboxes/FullBNT-1.0.7/netlab3.3/hintmat.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function [xvals, yvals, color] = hintmat(w);
Daniel@0 2 %HINTMAT Evaluates the coordinates of the patches for a Hinton diagram.
Daniel@0 3 %
Daniel@0 4 % Description
Daniel@0 5 % [xvals, yvals, color] = hintmat(w)
Daniel@0 6 % takes a matrix W and returns coordinates XVALS, YVALS for the
Daniel@0 7 % patches comrising the Hinton diagram, together with a vector COLOR
Daniel@0 8 % labelling the color (black or white) of the corresponding elements
Daniel@0 9 % according to their sign.
Daniel@0 10 %
Daniel@0 11 % See also
Daniel@0 12 % HINTON
Daniel@0 13 %
Daniel@0 14
Daniel@0 15 % Copyright (c) Ian T Nabney (1996-2001)
Daniel@0 16
Daniel@0 17 % Set scale to be up to 0.9 of maximum absolute weight value, where scale
Daniel@0 18 % defined so that area of box proportional to weight value.
Daniel@0 19
Daniel@0 20 w = flipud(w);
Daniel@0 21 [nrows, ncols] = size(w);
Daniel@0 22
Daniel@0 23 scale = 0.45*sqrt(abs(w)/max(max(abs(w))));
Daniel@0 24 scale = scale(:);
Daniel@0 25 color = 0.5*(sign(w(:)) + 3);
Daniel@0 26
Daniel@0 27 delx = 1;
Daniel@0 28 dely = 1;
Daniel@0 29 [X, Y] = meshgrid(0.5*delx:delx:(ncols-0.5*delx), 0.5*dely:dely:(nrows-0.5*dely));
Daniel@0 30
Daniel@0 31 % Now convert from matrix format to column vector format, and then duplicate
Daniel@0 32 % columns with appropriate offsets determined by normalized weight magnitudes.
Daniel@0 33
Daniel@0 34 xtemp = X(:);
Daniel@0 35 ytemp = Y(:);
Daniel@0 36
Daniel@0 37 xvals = [xtemp-delx*scale, xtemp+delx*scale, ...
Daniel@0 38 xtemp+delx*scale, xtemp-delx*scale];
Daniel@0 39 yvals = [ytemp-dely*scale, ytemp-dely*scale, ...
Daniel@0 40 ytemp+dely*scale, ytemp+dely*scale];
Daniel@0 41