changeset 16895:b8c37a855074

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.
author Ben Abbott <bpabbott@mac.com>
date Thu, 04 Jul 2013 07:54:28 -0400
parents 068f26c93ac7
children 498b2dd1bd56 21d5e76891fe
files scripts/plot/findobj.m
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/findobj.m	Wed Jul 03 20:38:05 2013 -0700
+++ b/scripts/plot/findobj.m	Thu Jul 04 07:54:28 2013 -0400
@@ -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)