Prev: 4D contourplot!
Next: lsqcurvefit
From: Roger Stafford on 11 Mar 2010 17:52 gudny <gudnyg(a)gmail.com> wrote in message <ad9f2a23-be16-42f6-9e74-2afcff9cd825(a)i25g2000yqm.googlegroups.com>... > Ok, so I have one solution: ..... You might try this. It uses only one call to 'unique'. The result is placed in B. T = A.'; p = T(:,1)==1; T(p,:) = 1-T(p,:); % Complement T rows that have 1 in first col. [t,m,t] = unique(T,'rows'); % Reduce to unique T rows ('last') B = A(:,sort(m)); % Reduce to corresponding cols. in A Roger Stafford
From: gudny on 15 Mar 2010 06:41
On 11 Mrz., 23:52, "Roger Stafford" <ellieandrogerxy...(a)mindspring.com.invalid> wrote: > gudny<gud...(a)gmail.com> wrote in message <ad9f2a23-be16-42f6-9e74-2afcff9cd...(a)i25g2000yqm.googlegroups.com>... > > Ok, so I have one solution: ..... > > You might try this. It uses only one call to 'unique'. The result is placed in B. > > T = A.'; > p = T(:,1)==1; > T(p,:) = 1-T(p,:); % Complement T rows that have 1 in first col. > [t,m,t] = unique(T,'rows'); % Reduce to unique T rows ('last') > B = A(:,sort(m)); % Reduce to corresponding cols. in A > > Roger Stafford Thank you, that is if course a lot simpler and faster! |