フィルターのクリア

Is that possible to find the correlation between this two histogram

18 ビュー (過去 30 日間)
Chuah Hsiang
Chuah Hsiang 2017 年 1 月 6 日
回答済み: Kush 2023 年 7 月 8 日
I get 2 histogram and I wish to find the correlation between this two graph.
Is that possible to get it ??

回答 (1 件)

Kush
Kush 2023 年 7 月 8 日
Use the Histcounts function to get the data and then apply correlation function to get the desired output
data1 = randn(1000, 1); %replace this with data for first histogram
data2 = randn(1000, 1); %replace this with data for second histogram
% Define the number of bins for the histograms
numBins = 20;
% Create the first histogram
[counts1, edges1] = histcounts(data1, numBins);
% Create the second histogram
[counts2, edges2] = histcounts(data2, numBins);
% Calculate the correlation coefficient between the two histograms
correlation = corr(counts1', counts2');
% Plot the histograms figure;
bar(edges1(1:end-1), counts1, 'FaceColor', 'blue');
hold on;
bar(edges2(1:end-1), counts2, 'FaceColor', 'red');
hold off;
legend('Histogram 1', 'Histogram 2');
% Display the correlation coefficient
disp(['Correlation coefficient: ' num2str(correlation)]);
Correlation coefficient: 0.8997

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by