Hinton Diagram Using 3 matrix

2 Ansichten (letzte 30 Tage)
Tahereh Aram
Tahereh Aram am 10 Mär. 2015
Bearbeitet: Tahereh Aram am 5 Sep. 2020
H

Antworten (1)

Christiaan
Christiaan am 11 Mär. 2015
Hello Tahereh,
In your question you defined three matrixes x(i), y(i) and z(i). However a matrix is an 2D (or higher) array, and therefore cannot be possible. Please refine your question if nessesary.
In file below, i made a code for you (constructed from two files (1) and (2) in the file exchange) how to make an Hinton diagramm from a matrix w:
clc;clear all;close all;
w = magic(5)
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));
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];
xmax = 640; ymax = 480;
% Offset bottom left hand corner
x01 = 40; y01 = 40; x02 = 80; y02 = 80;
% Need to allow 5 pixels border for window frame: but 30 at top
border = 5; top_border = 30;
ymax = ymax - top_border; xmax = xmax - border;
% Try to preserve aspect ratio approximately
if (8*size(w, 1) < 6*size(w, 2))
delx = xmax; dely = xmax*size(w, 1)/(size(w, 2));
else
delx = ymax*size(w, 2)/size(w, 1); dely = ymax;
end
h = figure('Color', [0.5 0.5 0.5], ...
'Name', 'Hinton diagram', ...
'NumberTitle', 'off', ...
'Colormap', [0 0 0; 1 1 1], ...
'Units', 'pixels', ...
'Position', [x01 y01 delx dely]);
set(gca, 'Visible', 'off', 'Position', [0 0 1 1]);
hold on
patch(xvals', yvals', color', 'Edgecolor', 'none');
axis equal;
Good luck! Christiaan

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by