How to compare counts of each histogram

조회 수: 5 (최근 30일)
Stephen john
Stephen john 2022년 6월 14일
편집: Stephen john 2022년 6월 15일
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
Stephen john
Stephen john 2022년 6월 14일
@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 2022년 6월 15일
편집: Stephen john 2022년 6월 15일
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

댓글을 달려면 로그인하십시오.

답변 (1개)

Saksham Gupta
Saksham Gupta 2022년 6월 14일
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
Image Analyst
Image Analyst 2022년 6월 14일
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 2022년 6월 14일
@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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by