I'm pretty sure someone already answered this today for you and told you that you need to get the bin counts. Look what happens if you leave off the semicolon -- you get an object with all kinds of properties on it:
>> h1 = histogram(rand(1, 1000))
h1 =
Histogram with properties:
Data: [1×1000 double]
Values: [95 93 86 107 101 114 96 97 109 102]
NumBins: 10
BinEdges: [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1]
BinWidth: 0.1
BinLimits: [0 1]
Normalization: 'count'
FaceColor: 'auto'
EdgeColor: [0 0 0]
So you need to do something like:
h1 = histogram(data1);
h2 = histogram(data2, h1.BinEdges); % Make sure it has the same bin edges as the first histogram.
counts1 = h1.Values;
counts2 = h2.Values;
Dist12 = sqrt(sum((counts1 - counts2) .^ 2));
or whatever you want to do or whatever formula you want.