hello,
I have an array like
{86558,29952,29809,29804,29750,29749,29556,29382,29379,28474,15093,14974,14234,14136}
and my threshold is 3000 for checking their closeness to each other. I want to categorize them for example ~86k appears 1, ~29k appears 9, ~14k appears 3 times. I need this result like avg(~29k numbers) and their repetition time. How I can do this? I couldn't figure out. thanks.

 채택된 답변

dpb
dpb 2017년 12월 3일
편집: dpb 2017년 12월 3일

1 개 추천

Assume your data are sorted as shown; if not sort first.
thsh=3000; % threshold for group difference screening
nGrps=sum(abs(diff(data))>thrsh)+1; % number of groups with that difference or more
C=clusterdata(data(:),'maxclust',nGrps); % do the cluster with those groups C is index to grp
cnts=accumarray(C,1); % the counts of each group
gmns=accumarray(C,data(:),[],@mean); % compute means of each group
NB: the (:) on data array to ensure have column vector as argument irrespective of actual orientation.

추가 답변 (1개)

Image Analyst
Image Analyst 2017년 12월 3일

0 개 추천

You can use pdist2() to find the "distance" of every element to every other element, if you have the Statistics and Machine Learning Toolbox:
v = [86558,29952,29809,29804,29750,29749,29556,29382,29379,28474,15093,14974,14234,14136]
distances = pdist2(v', v')
closeDistances = distances < 3000 % A logical matrix of whether they're close or not.

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

제품

질문:

2017년 12월 3일

답변:

2017년 12월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by