# HG changeset patch # User Ben Abbott # Date 1372938868 14400 # Node ID b8c37a855074b566a656c6d628ffeff0814a05ac # Parent 068f26c93ac7bf395b7c51214cd3b2d78ce2732e Modify findobj() to work with cells and structures. * scripts/plot/findobj.m: Use isequal() to compare properties that are not char or numeric. Add test. diff --git a/scripts/plot/findobj.m b/scripts/plot/findobj.m --- a/scripts/plot/findobj.m +++ b/scripts/plot/findobj.m @@ -220,10 +220,12 @@ match = 0; endif elseif (numel (p.(pname{np})) == numel (pvalue{np})) - if (ischar (pvalue{np})) + if (ischar (pvalue{np}) && ischar (p.(pname{np}))) match = strcmpi (pvalue{np}, p.(pname{np})); + elseif (isnumeric (pvalue{np} && isnumeric (p.(pname{np})))) + match = (pvalue{np} == p.(pname{np})); else - match = (pvalue{np} == p.(pname{np})); + match = isequal (pvalue{np}, p.(pname{np})); endif else match = 0; @@ -288,3 +290,12 @@ %! end_unwind_protect %! assert (h2, h1) +%!test +%! hf = figure ("visible", "off"); +%! h1 = subplot (2, 2, 1); +%! h2 = subplot (2, 2, 2); +%! h3 = subplot (2, 2, 3); +%! h4 = subplot (2, 2, 4); +%! userdata = struct ("foo", "bar"); +%! set (h3, "userdata", userdata); +%! assert (findobj (hf, "userdata", userdata), h3)