[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Making "intersect" work with cell array of strings
From: |
Michael Goffioul |
Subject: |
Making "intersect" work with cell array of strings |
Date: |
Fri, 24 Aug 2007 15:28:09 +0200 |
The attached patch allows to use intersect with cell arrays of strings.
Michael.
2007-08-24 Michael Goffioul <address@hidden>
* intersect.m: make it work with cell arrays of strings
Index: ../../../octave-cvs/scripts/set/intersect.m
===================================================================
RCS file: /cvs/octave/scripts/set/intersect.m,v
retrieving revision 1.4
diff -c -p -r1.4 intersect.m
*** ../../../octave-cvs/scripts/set/intersect.m 22 Jan 2007 17:29:53
-0000 1.4
--- ../../../octave-cvs/scripts/set/intersect.m 24 Aug 2007 13:25:51 -0000
*************** function [c, ia, ib] = intersect (a, b)
*** 46,52 ****
c = [a(:); b(:)];
[c, ic] = sort (c); ## [a(:);b(:)](ic) == c
! ii = find( c(1:end-1) == c(2:end) );
c = c(ii); ## The answer
ia = ja(ic(ii)); ## a(ia) == c
--- 46,56 ----
c = [a(:); b(:)];
[c, ic] = sort (c); ## [a(:);b(:)](ic) == c
! if (iscellstr (c))
! ii = find (strcmp (c(1:end-1), c(2:end)));
! else
! ii = find( c(1:end-1) == c(2:end) );
! endif
c = c(ii); ## The answer
ia = ja(ic(ii)); ## a(ia) == c
- Making "intersect" work with cell array of strings,
Michael Goffioul <=