function [ldistvec, matched_B_quants] = medians_B_d(ldist,matched_B,index,a,b,c)
% Function to calculate the median of each distance bin of matched magnetic
% field (B) data points
ldistb=discretize(ldist{index},a:b:c);
for i = 1:length([a:b:c])-1
   matched_B_quants(:,i) = quantile(abs(matched_B{index}(ldistb==i)),[0.25 0.5 0.75]);
end
ldistvec = a+b/2:b:c-b/2;
end