File Exchange Pick of the Week

Our best user submissions

Two dimensional histogram

The other day I was doing a Monte Carlo analysis where I had two independent varables and one scalar output. A good visualization for this is a two dimensional histogram. Unfortunatly, these are not directly supported in MATLAB, but thankfully Kangwon Lee has developed one and shared it with the rest of us. This code came with a good example, and was well documented. These things are often overlooked (Hint, Hint Hint), so I am glad to see they were done this time. This is the code I used to create the screenshot you see here, mostly a de-generalization of the example with a more intuitive dataset: N = 160000; nBins = 30; z = randn(N, 2); edges = linspace(-1,1,nBins); mHist2d = hist2d(z,edges,edges); edgeLabel = 0.5*(edges(1:end-1)+edges(2:end)); pcolor(edgeLabel, edgeLabel,mHist2d); colormap(pink); colorbar title('2d hist of two normally distributed random variables')  
|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.