Histogram error at euclidian distance
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Theodora Chivu
am 8 Mai 2020
Beantwortet: Image Analyst
am 8 Mai 2020
Operator '-' is not supported for operands of type 'matlab.graphics.chart.primitive.Histogram'.
Dist1(i) = sqrt(sum((h1-h(i)).^2));
Both h are histogram objects.
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 8 Mai 2020
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.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!