Mercurial > hg > octave-nkf
diff scripts/plot/findobj.m @ 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 | 092d0a685546 |
children | 21d5e76891fe |
line wrap: on
line diff
--- 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)