I have this code:
a = [1 1 1 3 3 5];
b = [1 3 3 3 5 5];
edges{1} = [0 2 4 6];
edges{2} = [0 2 4 6];
edges = edges';
h = hist3([a' b'],'Edges',edges)
The output h is 4x4 matrix,
1 2 0 0
0 1 1 0
0 0 1 0
0 0 0 0
However I think it should have been 3x3 since I have 4 entries for the edges, i.e
0-2,
2-4,
4-6
What's going on?
The definition of the edge
handle in hist3
is :
edges{1}(i) <= X(k,1) < edges{1}(i+1)
So in your case:
0<= x <2,
2<= x <4,
4<= x <6,
6<= x
Because it has the <=
logic, the last (4th) part of the histogram are for values that exactly equal 6
.
If you dont like it you can just delete the last row \ column of h
h(:,end)=[];
h(end,:)=[];