I have 2 vectors that I am comparing. I am using 1 as the "bin edges" and the other one is the data I want a count of. Histc seems to be the way to go for this, and does give me the count I want.
However, I also want to find the index of the first value in each bin, so I can use the actual data value for other calculations.
Example: There are 4 bins, 1-2, 2-3, 3-4, 4-5
x=[1 2 3 4 5];y=[.8 .9 1 1.2 1.8 2.1 3.1 3.2 5 6 7 8 9 10];n_elements=histc(y,x);n_elements(length(n_elements))=[];n_elements=[3 1 2 0]
The problem I am having is I need a way to find the index of the first y value in each bin. I want something like: y_index(1)=3, y_index(2)=6, y_index(3)=7, y_index(4)=[]
Best Answer