Why does histogram data from hist3 have to be transposed?
Mostrar comentarios más antiguos
I just learnt how to use hist3 and I don't understand a couple of lines in the example code that Matlab help provided. I've copy pasted the example for plotting a density histogram with intensity map (an intensity map is what I'm interested in plotting actually). The two lines that I don't understand are: 1. n1 = n'; --> why does the histogram have to be transposed? 2. h.ZData = ones(size(n1)) * -max(max(n)); --> what does this line do?
%Load the sample data.
load seamount
%Correct grid for negative y-values and draw histogram in 2D.
hold on
dat = [-y,x];
hist3(dat)
%Extract histogram data.
n = hist3(dat); % default is to 10x10 bins
n1 = n';
n1(size(n,1) + 1, size(n,2) + 1) = 0;
%Generate grid for 2-D projected view of intensities.
xb = linspace(min(dat(:,1)),max(dat(:,1)),size(n,1)+1);
yb = linspace(min(dat(:,2)),max(dat(:,2)),size(n,1)+1);
%Make a pseudocolor plot.
h = pcolor(xb,yb,n1);
h.ZData = ones(size(n1)) * -max(max(n));
colormap(hot) % heat map
title('Seamount:Data Point Density Histogram and Intensity Map');
grid on
view(3);
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Agriculture en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!