## Matlab Hist3 Beispiel Essay

Hello, I have two vectors

X = [-1 -5 3 6 -1 7]; Y = [-1 -6 3 6 -1 7];I want to plot the corresponding number of times each (x,y) couple appears in those vectors on a imagesc plot. For example the couple (-1,-1) appears twice, and all the others only once.

To do so I tried to first use the MATLAB function hist3 to get a 2D histogram of my data:

hist3([X', Y'],[numel(X) numel(Y)]);This returns the following graph, which looks correct:

But I don't find a 2D histogram very clear and I wanted to use a contour plot to display my data. To use imagesc I did

N = hist3([X', Y'],[numel(X) numel(X)]); figure imagesc(X,Y,N); colorbarwhich returns the foolowing graph:

which is absolutely not what I am looking for. The axis are completely out. According to MATLAB documentation, N is "a matrix containing the number of elements of "[X', Y']" that fall in each bin of the grid", it seems to be OK for what I want. Does anybody has an idea on what I am missing here?

## Syntax

## Description

bins the elements of the *m*-by-2 matrix into a 10-by-10 grid of equally spaced containers, and plots a histogram. Each column of corresponds to one dimension in the bin grid.

plots a histogram using an -by- grid of bins. is equivalent to .

, where is a two-element cell array of numeric vectors with monotonically non-decreasing values, uses a 2-D grid of bins centered on in the first dimension and on in the second. assigns rows of falling outside the range of that grid to the bins along the outer edges of the grid, and ignores rows of containing s. is equivalent to .

, where is a two-element cell array of numeric vectors with monotonically non-decreasing values, uses a 2-D grid of bins with edges at in the first dimension and at in the second. The (*i*, *j*)th bin includes the value if

Rows of that fall on the upper edges of the grid, or , are counted in the th or th bins, where and are the lengths of and . does not count rows of falling outside the range of the grid. Use and in to include all non- values.

returns a matrix containing the number of elements of that fall in each bin of the grid, and does not plot the histogram.

returns the positions of the bin centers in a 1-by-2 cell array of numeric vectors, and does not plot the histogram. plots onto an with handle instead of the current . See the reference page for more information about handles to plots.

allows you to specify graphics parameter name/value pairs to fine-tune the plot.

## One thought on “Matlab Hist3 Beispiel Essay”