Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Remove Duplicate Values according to criterion
Date: Fri, 11 May 2012 18:58:28 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 25
Message-ID: <jojngk$92j$1@newscl01ah.mathworks.com>
References: <jojhvn$coj$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1336762708 9299 172.30.248.37 (11 May 2012 18:58:28 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 11 May 2012 18:58:28 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:767564

"Shantharam " <ksramrepome@gmail.com> wrote in message <jojhvn$coj$1@newscl01ah.mathworks.com>...
> I have two matrices
> 
> ampmat = [68.75539589	70.70627741	72.0721373	80.32433467	8.875643035	4.472189209	1.966101838	1.418783172	0.919213277	0.812347605	0.715597877	0.656760549	0.688455694	0.859875845	1.045734641	1.827282907	3.753959435	5.614435942	3.646970094	3.708414655	3.345146553	3.363855225	2.433320998	1.738680617	1.199803437	0.82070146	0.782401601	0.96851817	1.181695482	1.519064218	1.344429667	0.720952257];
> 
> decisionmat = [1 	2	3	4	5	6	7	8	9	9	11	11	13	14	14	15	16	17	17	18	20	20	20	22	23	24	26	27	27	28	28	27];
> 
> Here each element of decisionmat corresponds each element of ampmat respectively. i.e., 1 corresponds to 68.75, 2 corresponds to 70.70 and so on.
> 
> Now we can see that in decisionmat there are duplicate elements of 9,11,14,17,20,27,28. I want final matrix without those duplicate elements. while removing those duplicates I hav a criterion which is i should have only that duplicate whose corresponding ampmat value is maximum among its duplicates i.e., 20 has three duplicates with ampmat values 3.345146553,	3.363855225,2.433320998.
> 
> I want 20 corresponding to max 3.3638.my final matrices should be
> 
> fin1 = [1 2 3 4 5 6 7 8 9  11  13 14 15 16 17 18  20 22 23 24 26 27 28 ];
> 
> fin2 =[68.75539589	70.70627741	72.0721373	80.32433467	8.875643035	4.472189209	1.966101838	1.418783172	0.919213277
>  0.715597877  0.688455694  1.045734641	1.827282907	3.753959435	5.614435942  3.708414655  3.363855225  1.738680617	1.199803437	0.82070146	0.782401601  1.181695482	1.519064218 ]
> 
> Plz help me with code
- - - - - - - - -
 [a,p] = sort(ampmat);
 [fin1,m] = unique(decisionmat(p),'last');
 fin2 = a(m);

Roger Stafford