Mercurial > hg > octave-nkf
diff scripts/set/setdiff.m @ 5182:5b361aa47dff
[project @ 2005-03-03 06:21:47 by jwe]
author | jwe |
---|---|
date | Thu, 03 Mar 2005 06:21:47 +0000 |
parents | 41cd70503c72 |
children | 4c8a2e4e0717 |
line wrap: on
line diff
--- a/scripts/set/setdiff.m +++ b/scripts/set/setdiff.m @@ -18,12 +18,10 @@ ## 02111-1307, USA. ## -*- texinfo -*- -## @deftypefn {Function File} {} setdiff(@var{a}, @var{b}) -## -## Return the elements in @var{a} but not in @var{b}, sorted in ascending -## order. If @var{a} and @var{b} are both column vectors return a column -## vector, otherwise return a row vector. -## +## @deftypefn {Function File} {} setdiff (@var{a}, @var{b}) +## Return the elements in @var{a} but not in @var{b}, sorted in +## ascending order. If @var{a} and @var{b} are both column vectors +## return a column vector, otherwise return a row vector. ## @end deftypefn ## @seealso{unique, union, intersect, setxor, ismember} @@ -38,13 +36,13 @@ c = unique (a); if (! isempty (c) && ! isempty (b)) - ## form a and b into combined set + ## Form a and b into combined set. b = unique (b); [dummy, idx] = sort ([c(:); b(:)]); - ## eliminate those elements of a that are the same as in b + ## Eliminate those elements of a that are the same as in b. n = length (dummy); c(idx(find (dummy(1:n-1) == dummy(2:n)))) = []; - ## reshape if necessary + ## Reshape if necessary. if (size (c, 1) != 1 && size (b, 1) == 1) c = c.'; endif