0

I have small query. I have two data sets. In one data sets for example I did binning and calculated the mean value and std value along with group binning. Now in I have second data sets of same parameters say X. I would like identify this X data sets belong to which bin groups of my previous data sets using matlab.

Could you give some example how to identify the incoming data points belongs to which bin group...??

I used following binning which is available in matlab :

  binEdges = linspace(botEdge, topEdge, numBins+1);
  [h,whichBin] = histc(x, binEdges);
Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
ravi pandit
  • 117
  • 12

1 Answers1

0

Well... you already have your bin edges. Anything inside specific edges is in that bin.

If you know that the data is inside the ranges you defined then, for each new data

newdatabin=find(newdata>binedges,1,'last'); %this is the bin number where the new data goes in

h(newdatabin)=h(newdatabin)+1; %add one!

Also consider using histcounts if your MATLAB version is new enough.

Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
  • Thank you for your quick response. I will try with that one. Could you tell me what here we can do with histcount ? yesterday I install Matlab 2016 version which have this function. thanks in advance :) – ravi pandit Jul 18 '16 at 11:17
  • @ravipandit it is a better version of `histc`, does the same thing. If this answer helps you consider accepting it – Ander Biguri Jul 18 '16 at 11:50