Histogram error at euclidian distance
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Image Analyst
2020 年 5 月 8 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!