20 if ~isa(obj,
" handle ") && ~isstruct(obj)
21 error(
" The argument must either be a handle class or a struct. ");
29 type,inputname(1),
class(obj));
31 t.addRow(
" Location ",
" Class ",
" ID ",
" Parent ",varargin[:]);
33 warning(
" off ",
" MATLAB:structOnObject ");
34 findinst_recur(obj, inputname(1),
true);
35 warning(
" on ",
" MATLAB:structOnObject ");
37 function findinst_recur(obj, lvl, checkloop)
38 if checkloop && any(cellfun(@(o)isequal(o,obj),visited))
45 findinst_recur(obj[l], sprintf(
" %s{%d} ",lvl,l),
false);
49 findinst_recur(obj(l), sprintf(
" %s(%d) ",lvl,l),
false);
53 if isa(obj,
" handle ")
64 for idx = 1:length(fn)
65 if ~isempty(os.(fn[idx]))
67 thislvl = [lvl
" . " fn[idx]];
69 matches[end+1] = prop;
73 locations[end+1] = thislvl;
76 if any(cellfun(@(o)isequal(o,
" ID "),fieldnames(prop)))
79 props =
cell(1,length(varargin));
80 for k = 1:length(varargin)
81 if isprop(prop,varargin[
k]) || isfield(prop,varargin[k])
82 props[
k] = prop.(varargin[
k]);
84 props[
k] =
" doesn "" t exist ";
87 t.addRow(thislvl,
class(prop),st,
class(obj),props[:]);
89 if isa(prop,
" handle ") || isstruct(prop)
92 findinst_recur(prop, thislvl,
true);
A MatLab cell array or matrix.
function [ PrintTable t , cell matches , parents , cell locations ] = FindInstance(handle obj,char type, varargin)
FindInstance: Locate instances of certain classes within a class or a struct.
Matlab's base handle class (documentation generation substitute)
A variable number of input arguments.
PrintTable: Class that allows table-like output spaced by tabs for multiple rows. ...