I'm having trouble with this routine. In the example below, the x and y ranges dont' seem to be correct, and also the distribution doesn't look right either.
function hist3_test
close all; clc;
events = 1000000;
xrange=0:.1:1;
nxs=length(xrange);
x=[]; y=[];
for xx=0:.1:1
xs=xx+sqrt(0.005)*randn(round(events/nxs),1);
if (xx<.3)
ys=cos(xs)+ sqrt(0.001)*randn(round(events/nxs),1);
else
ys=cos(xs)+ sqrt(0.1)*randn(round(events/nxs),1);
end
x = [x; xs];
y = [y; ys];
end
% For linearly spaced edges:
figure;
subplot(2,1,1);
plot(x,y,'.');
xedges = linspace(-1,1,64); yedges = linspace(-1,1,64);
histmat = hist2(x, y, xedges, yedges);
subplot(2,1,2);
% pcolor(xedges,yedges,histmat'); colorbar ; axis square tight ;
izero = histmat==0;
histmat(izero) = nan;
h=pcolor(xedges,yedges,histmat'); colorbar ; axis square tight ;
set(h,'edgecolor','none');
end
Comment only