How do I bin data from two different groups into bins centered around the same value?
As a toy example,
A(:,1) = [0.05:0.05:0.80]';
A(:,2) = [ones(7,1); [0.6; 0.6; 0.4]; zeros(6,1)];
B(:,1) = [0.15:0.1:0.95]';
B(:,2) = [ones(4,1); [0.8; 0.8; 0.2]; zeros(2,1)];
plot(A(:,1),A(:,2)); hold on; plot(B(:,1),B(:,2));
I'd like to bin and plot A and B on the same plot, but with the data binned at points 0.2, 0.4, 0.6, and 0.8 on the X-Axis for both A and B, meaning that there'll be uneven data in each bin. How should I go about group these values with a mean centered around those points?