I am confused by the
[m,n]=hist(y,x)
such as
M = [1, 2, 3;
4, 5, 6;
1, 2, 3];
[m,n] = hist(M,1:3)
Which results in
m = 2 0 0
0 2 0
1 1 3
Can someone please explain how m is calculated?
I am confused by the
[m,n]=hist(y,x)
such as
M = [1, 2, 3;
4, 5, 6;
1, 2, 3];
[m,n] = hist(M,1:3)
Which results in
m = 2 0 0
0 2 0
1 1 3
Can someone please explain how m is calculated?
Copyright © 2021 Jogjafile Inc.
histactually takes vectors as input arguments, you wrote a matrix, so it just handles your input as if it was several vector-inputs. The output are the number of elements for each container (in your case1:3, the second argument).treats each column as one input. You put in 3 inputs (# of columns) and you get 3 outputs.
means, for the input
[1;4;1]and the bin1:3two elements are in bin 1 and one element is in bin 3.Look at the last column of
m, here all three values are in the third bin, which makes sense, since the corresponding vector is[3;6;3], and out of those numbers all have to go into the bin/container 3.