How to compare counts of each histogram

2 views (last 30 days)
Stephen john
Stephen john on 14 Jun 2022
Edited: Stephen john on 15 Jun 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 Comments
Stephen john
Stephen john on 15 Jun 2022
Edited: Stephen john on 15 Jun 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

Sign in to comment.

Answers (1)

Saksham Gupta
Saksham Gupta on 14 Jun 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 Comments
Stephen john
Stephen john on 14 Jun 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

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by