## Copyright (C) 2010 Soren Hauberg ## ## This program 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 3 of the License, or (at ## your option) any later version. ## ## This program 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 this program; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn address@hidden =} struct2handle (@var{s}) ## @end deftypefn function h = struct2handle (s) ## Check input if (nargin != 1) error ("struct2handle: wrong number of input arguments"); endif if (!isstruct (s)) error ("struct2handle: input argument must be a structure"); endif ## Do the actual work h = feval (s.type); # I assume that 'type' corresponds to the name of a function (e.g. 'figure') for [value, property] = s.properties try set (h, property, value); catch warning ("struct2handle: ignoring property '%s'", property); end_try_catch endfor if (isfield (s, "children")) for k = 1:length (s.children) struct2handle (s.children (k)); endfor endif endfunction