# HG changeset patch # User Ben Abbott # Date 1274917752 14400 # Node ID 3df114a44da3d328baa4249d28feb73e01ae9ded # Parent 4cdc43c095c58f71e667d6b43fe7a8899d6ac89a ancestor.m: Support vectors of handles. diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2010-05-26 Ben Abbott + + * plot/ancestor.m: Support vectors of handles. + 2010-05-26 Rik * sparse/svds.m: Initialize ARPACK starting vector in svds test code. Bug #29721. diff --git a/scripts/plot/ancestor.m b/scripts/plot/ancestor.m --- a/scripts/plot/ancestor.m +++ b/scripts/plot/ancestor.m @@ -35,7 +35,7 @@ function p = ancestor (h, type, toplevel) if (nargin == 2 || nargin == 3) - p = []; + p = cell (numel (h), 1); if (ischar (type)) type = { type }; endif @@ -48,18 +48,24 @@ error ("ancestor: third argument must be \"toplevel\""); endif endif - while (true) - if (isempty (h) || ! ishandle (h)) - break; - endif - if (any (strcmpi (get (h, "type"), type))) - p = h; - if (look_first) + h = num2cell (h); + for nh = 1:numel(h) + while (true) + if (isempty (h{nh}) || ! ishandle (h{nh})) break; endif - endif - h = get (h, "Parent"); - endwhile + if (any (strcmpi (get (h{nh}, "type"), type))) + p{nh} = h{nh}; + if (look_first) + break; + endif + endif + h{nh} = get (h{nh}, "Parent"); + endwhile + endfor + if (nh == 1) + p = p{1}; + endif else error ("ancestor: second argument must be a string or cell array of strings"); endif