[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is there a function similar to matlab gcf?
From: |
David Grohmann |
Subject: |
Re: Is there a function similar to matlab gcf? |
Date: |
Tue, 03 Oct 2006 14:43:40 -0500 |
User-agent: |
Thunderbird 1.5.0.7 (Windows/20060909) |
David Bateman wrote:
frank wang wrote:
Sorry for the confusion. gcf is the function from matlab:
GCF Get handle to current figure.
H = GCF returns the handle of the current figure. The current
figure is the window into which graphics commands like PLOT,
TITLE, SURF, etc. will draw.
The handle of the current figure is stored in the root
property CurrentFigure, and can be queried directly using GET,
and modified using FIGURE or SET.
Clicking on uimenus and uicontrols contained within a figure,
or clicking on the drawing area of a figure cause that
figure to become current.
The current figure is not necessarily the frontmost figure on
the screen.
GCF should not be relied upon during callbacks to obtain the
handle of the figure whose callback is executing - use GCBO
for that purpose.
See also figure, close, clf, gca, gcbo, gco, gcbf.
Basically, in our code, we need to get the current figure number. I just
realized that since it is related with graphics command, most likely
octave will not have this command.
Hey FRank,
We're a community, propose a patch for setdiff would be the fastest way
for setdiff to support this feature..
As for gcf, this is a handle graphics feature, and there has been long
discussions about adding all of these compatibility features, and its
timetabled for octave 3.1 next year.
If you just want the current figure number then in 2.9.9, then one nasty
unsupported way of doing it is a function
function h = get_current_figure()
global __CUrrent_figure__;
h = __current_figure__;
end
Don't think this works in 2.1.73 though...
D.
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.
|
## Copyright (C) 2000 Paul Kienzle
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2, or (at your option)
## any later version.
##
## Octave is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING. If not, write to the Free
## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
## -*- texinfo -*-
## @deftypefn {Function File} {} setdiff (@var{a}, @var{b})
## @deftypefnx {Function File} {} setdiff(@var{a}, @var{b}, "rows")
## Return the elements in @var{a} that are 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.
##
## Given the optional third argument @samp{"rows"}, return the rows in
## @var{a} that are not in @var{b}, sorted in ascending order by rows.
## @seealso{unique, union, intersect, setxor, ismember}
## @end deftypefn
## Author: Paul Kienzle
## Adapted-by: jwe
function [c, ia] = setdiff (a, b, byrows)
if (nargin < 2 || nargin > 3)
usage ("setdiff (a, b) or setdiff (a, b, \"rows\")");
endif
if (nargin == 3)
if (! strcmpi (byrows, "rows"))
error ("expecting third argument to be \"rows\"");
else
byrows = true;
endif
else
byrows = false;
endif
if (byrows)
c = unique (a, "rows");
if (! isempty (c) && ! isempty (b))
## Form a and b into combined set.
b = unique (b, "rows");
[dummy, idx] = sortrows ([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))), :) = [];
endif
else
[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);
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.';
endif
endif
endif
endfunction
%!assert(setdiff(["bb";"zz";"bb";"zz"],["bb";"cc";"bb"],"rows"), "zz")
%!assert(setdiff(["b";"z";"b";"z"],["b";"c";"b"],"rows"), "z")
%!assert(setdiff(["b";"z";"b";"z"],["b";"c";"b"]), "z")
%!assert(setdiff([1, 1; 2, 2; 3, 3; 4, 4], [1, 1; 2, 2; 4, 4], "rows"), [3 3])
%!assert(setdiff([1; 2; 3; 4], [1; 2; 4], "rows"), 3)
- 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 <=
- 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, 2006/10/03
- 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