[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
setdiff patch
From: |
David Grohmann |
Subject: |
setdiff patch |
Date: |
Tue, 03 Oct 2006 15:25:14 -0500 |
User-agent: |
Thunderbird 1.5.0.7 (Windows/20060909) |
David Grohmann wrote:
John W. Eaton wrote:
On 3-Oct-2006, David Grohmann wrote:
| I needed some functionality in setdiff (probbaly the same thing you
are | looking for) that I guess is new in matlab. It took me a while
cus i | barely know matlab, but I only handled one of the cases,
set_diff has a | few cases. Maybe someone else can handle the rest,
as the project that | needed this was terminated.
When sending fixes or enhancements for functions that already exist,
please send context diffs relative to the version you started with.
It's rare that we would want to just replace the current version with
a new one since doing so may wipe out other changes that have been
made to the code that is currently in Octave. Also, please include at
least a description of the feature you are adding, the problem you are
trying to solve or the bug that you are fixing.
Thanks,
jwe
I actually did that on purpose so it would not be used to update
octave... yet. That version is only semi functioning. It should not be
used to replace anything until someone else finishes it.
here is the Diff if anyone wants it. This was either against a 2.1.73
version or a 2.9.* version. I don't know which, sorry for not being
more helpful there.
It returns an extra index, and I forgot why it was important and the
meaning of it, but it is the functionality that Frank needs.
Again sorry for being so vague, but I think Frank can take it from here.
This might help explain from the matlab help for setdiff
[c,i] = setdiff(...) also returns an index vector index such that c =
a(i) or c = a(i,:).
Figures I would forget to attach the patch.
--
David Grohmann
Senior Student Associate
Applied Research Lab : UT Austin : ESL - S206
Office: 512-835-3237
--- setdiff.m Wed May 3 15:03:41 2006
+++ newsetdiff.m Thu Jun 29 18:02:18 2006
@@ -32,7 +32,7 @@
## Author: Paul Kienzle
## Adapted-by: jwe
-function c = setdiff (a, b, byrows)
+function [c, ia] = setdiff (a, b, byrows)
if (nargin < 2 || nargin > 3)
usage ("setdiff (a, b) or setdiff (a, b, \"rows\")");
@@ -59,14 +59,16 @@
c(idx(find (dummy(1:n-1) == dummy(2:n))), :) = [];
endif
else
- c = unique (a);
+ [c, ia] = unique (a);
if (! isempty (c) && ! isempty (b))
## 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.
n = length (dummy);
- c(idx(find (dummy(1:n-1) == dummy(2:n)))) = [];
+ badidx=idx(find (dummy(1:n-1) == dummy(2:n)));
+ c(badidx) = [];
+ ia(badidx) = [];
## Reshape if necessary.
if (size (c, 1) != 1 && size (b, 1) == 1)
c = c.';
- Is there a function similar to matlab gcf?, frank wang, 2006/10/03
- Re: Is there a function similar to matlab gcf?, David Grohmann, 2006/10/03
- Re: Is there a function similar to matlab gcf?, frank wang, 2006/10/03
- Re: Is there a function similar to matlab gcf?, David Bateman, 2006/10/03
- Re: Is there a function similar to matlab gcf?, David Bateman, 2006/10/03
- Re: Is there a function similar to matlab gcf?, David Grohmann, 2006/10/03
- Re: Is there a function similar to matlab gcf?, John W. Eaton, 2006/10/03
- Re: Is there a function similar to matlab gcf?, David Grohmann, 2006/10/03
- setdiff patch,
David Grohmann <=
- Re: setdiff patch, Tom Holroyd (NIH/NIMH) [E], 2006/10/03
Re: Is there a function similar to matlab gcf?, Quentin Spencer, 2006/10/03