Dear All;
I have an array of two columns, I want to find each repeated values of y for each x value and then the max of these y value to this x value and make new matrix in which for each x value there is a unique y value
how to do that ?

댓글 수: 1

Walter Roberson
Walter Roberson 2014년 3월 6일
What do you want done if one of the y values is unique instead of being repeated?

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

 채택된 답변

Walter Roberson
Walter Roberson 2014년 3월 6일

0 개 추천

[uvals, ua, uc] = unique(xy(:,1));
maxy = accumarray(uc(:), xy(:,2), [], @max);
newarray = [uvals(:), maxy(:)];

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 3월 6일

0 개 추천

v=[1 2;1 3;4 5;4 20;10 30]
[ii,jj,kk]=unique(v(:,1))
out=[ii accumarray(kk,v(:,2),[],@max)]

카테고리

도움말 센터File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

제품

태그

Community Treasure Hunt

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

Start Hunting!

Translated by