From: Mr. CFD on 22 Jun 2010 05:09 Hi, a=[ .41 0.5 1 .71 1 1 0.05 .42 0.8 2 .22 2 2 0.05 .53 0.9 3 .43 3 3 0.01 .56 0.8 4 .84 4 4 0.05] ; b=[1 2 3 4 5 6 7] I'm trying to write a code whereby we can detect and delete duplicate data in column 'a'. For example we can see that a(:,3)==a(:,5)==a(:,6). I want to delete the repeating data in column in a(:,5) and a(:,6) only [not a(:,3), which is the first time we get this data]. I need to then modify variable b by using the index 5 and 6 to delete the corresponding value in b, such that b becomes b=[1 2 3 4 7]. I have tried using unique and histc but just get into a big mess. I'm sure there is a simple work around to this. Can you please suggest a possible solution?
From: Oleg Komarov on 22 Jun 2010 07:00 "Mr. CFD" <s2108860(a)student.rmit.edu.au> wrote in message <hvpujh$p80$1(a)fred.mathworks.com>... > Hi, > > a=[ .41 0.5 1 .71 1 1 0.05 > .42 0.8 2 .22 2 2 0.05 > .53 0.9 3 .43 3 3 0.01 > .56 0.8 4 .84 4 4 0.05] ; > > b=[1 2 3 4 5 6 7] > > I'm trying to write a code whereby we can detect and delete duplicate data in column 'a'. For example we can see that a(:,3)==a(:,5)==a(:,6). > > I want to delete the repeating data in column in a(:,5) and a(:,6) only [not a(:,3), which is the first time we get this data]. I need to then modify variable b by using the index 5 and 6 to delete the corresponding value in b, such that b becomes b=[1 2 3 4 7]. > > I have tried using unique and histc but just get into a big mess. I'm sure there is a simple work around to this. Can you please suggest a possible solution? [Out,b] = unique(a.','rows','first'); Out = Out.'; Up to you if you want to sort. Oleg
|
Pages: 1 Prev: How to display the image when I use two axes Next: combining matrices |