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