Mercurial > octave-nkf
comparison scripts/set/setdiff.m @ 10549:95c3e38098bf
Untabify .m scripts
author | Rik <code@nomad.inbox5.com> |
---|---|
date | Fri, 23 Apr 2010 11:28:50 -0700 |
parents | 5edee330d4cb |
children | be55736a0783 |
comparison
equal
deleted
inserted
replaced
10548:479536c5bb10 | 10549:95c3e38098bf |
---|---|
56 [dummy, idx] = sortrows ([c; b]); | 56 [dummy, idx] = sortrows ([c; b]); |
57 ## Eliminate those elements of a that are the same as in b. | 57 ## Eliminate those elements of a that are the same as in b. |
58 dups = find (all (dummy(1:end-1,:) == dummy(2:end,:), 2)); | 58 dups = find (all (dummy(1:end-1,:) == dummy(2:end,:), 2)); |
59 c(idx(dups),:) = []; | 59 c(idx(dups),:) = []; |
60 if (nargout > 1) | 60 if (nargout > 1) |
61 i(idx(dups),:) = []; | 61 i(idx(dups),:) = []; |
62 endif | 62 endif |
63 endif | 63 endif |
64 else | 64 else |
65 if (nargout > 1) | 65 if (nargout > 1) |
66 [c, i] = unique (a); | 66 [c, i] = unique (a); |
73 [dummy, idx] = sort ([c(:); b(:)]); | 73 [dummy, idx] = sort ([c(:); b(:)]); |
74 ## Eliminate those elements of a that are the same as in b. | 74 ## Eliminate those elements of a that are the same as in b. |
75 if (iscellstr (dummy)) | 75 if (iscellstr (dummy)) |
76 dups = find (strcmp (dummy(1:end-1), dummy(2:end))); | 76 dups = find (strcmp (dummy(1:end-1), dummy(2:end))); |
77 else | 77 else |
78 dups = find (dummy(1:end-1) == dummy(2:end)); | 78 dups = find (dummy(1:end-1) == dummy(2:end)); |
79 endif | 79 endif |
80 c(idx(dups)) = []; | 80 c(idx(dups)) = []; |
81 if (nargout > 1) | 81 if (nargout > 1) |
82 i(idx(dups)) = []; | 82 i(idx(dups)) = []; |
83 endif | 83 endif |
84 ## Reshape if necessary. | 84 ## Reshape if necessary. |
85 if (size (c, 1) != 1 && size (b, 1) == 1) | 85 if (size (c, 1) != 1 && size (b, 1) == 1) |
86 c = c.'; | 86 c = c.'; |
87 endif | 87 endif |
88 endif | 88 endif |
89 endif | 89 endif |
90 | 90 |
91 endfunction | 91 endfunction |