How to compare counts of each histogram

5 vues (au cours des 30 derniers jours)
Stephen john
Stephen john le 14 Juin 2022
Modifié(e) : Stephen john le 15 Juin 2022
Hello everyone, i hope you are doing well. i have the eight clusters. I want to calculate histogram for each cluster, after calculating histogram, i want to compare the count of each values if the count is greater in one cluster assign the value to other cluster and repeat the process till 8 clusters
How can i do that in MATLAB
I have the following code.
for i = 1:8
T = clusters{i}(:,2);
h1(i)=histogram(T,100000,'BinLimitsMode','manual','BinLimits',[0 3e8]);
end
  7 commentaires
Stephen john
Stephen john le 14 Juin 2022
@Rik @Image Analyst @Steven Lord Yes you are right, i want the group values if it using histogram it would be good. for example as you say that a person aged is 47 it has count value in one cluster for example 30, in the other cluster the same aged 47 exist and its count value if 10, as you see the count value in first cluster is greater (30) then in the other cluster(10). Now I want to to move the value from other cluster to first cluster which make the total count to 40.
I hope now you are clear
Stephen john
Stephen john le 15 Juin 2022
Modifié(e) : Stephen john le 15 Juin 2022
Now i have the cell array of 1x8. I have find the unique value and count for each cell.
Now i want to compare the values of every cell. for example if value 80000 exist in first cell. i want to find the same number in other cells. and it run untill values in all cells are compare with one another
Secondly, if value 8000 exist in other cell, then check it count.if count is less then other count, assign that counts to other cell.
The following code. The Values gives unique values from all cells. and count gives the number of time value exist in cell.
I want to use Both of them to compare values of each cells.
BindataF=cell(1,8)
for i = 1:8
T = clusters{i}(:,2);
h1(i)=histogram(T,100000,'BinLimitsMode','manual','BinLimits',[0 3e8]);
BindataF{i}=h1(i).Data;
T1=BindataF{i}
Values=unique(T1)
counts=histc(T1(:),Values)
end

Connectez-vous pour commenter.

Réponses (1)

Saksham Gupta
Saksham Gupta le 14 Juin 2022
As per my understanding, you are unable to find the count value of histograms whose data is present with you.
Values attribute helps us to get bin count in histogram in MATLAB
Following code will help you in getting a cell array having count values of each Histogram:
clusters=num2cell(load('matlab.mat'));
h1= cell(1,8);
for i = 1:8
T = clusters{1,1}.clusters{i,1}(:,2);
z =histogram(T,100000,'BinLimitsMode','manual','BinLimits',[0 3e8]);
disp(z.Values)
h1{i}=z.Values;
end
You may also refer to the following documentation:
  7 commentaires
Image Analyst
Image Analyst le 14 Juin 2022
And the explanation???
s = load('matlab.mat')
s = struct with fields:
clusters: {8×1 cell}
clusters = s.clusters % a cell array
clusters = 8×1 cell array
{40498×5 double} {10148×5 double} { 408×5 double} {12212×5 double} { 3429×5 double} { 1632×5 double} { 6976×5 double} { 2898×5 double}
for k = 1 : numel(clusters)
subplot(3, 3, k);
histogram(clusters{k});
grid on;
ylabel('Count');
xlabel('Value');
end
What do the 5 columns, and variable number of rows represent?
Stephen john
Stephen john le 14 Juin 2022
@Image Analyst The useful features are 2nd third and fourth column, in which we are going to develop an algorithm on each feature. if the 2nd column has the value of 23000 and its count is 500, if this value (23000) exist in 2nd column of any other clusters. and has count less than 500 then we assign the value to that cluster.
Have you understand that

Connectez-vous pour commenter.

Catégories

En savoir plus sur Parallel and Cloud dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by