time | Calls | line |
---|
| | 1 | function valid = isprop(varargin)
|
| | 2 | %ISPROP Returns true if the property exists.
|
| | 3 | % V = ISPROP(H, PROP) Returns true if PROP is a property of H.
|
| | 4 | % V is a logical array of the same size as H. Each true element of V
|
| | 5 | % corresponds to an element of H that has the property PROP.
|
| | 6 |
|
| | 7 | % Copyright 1988-2016 The MathWorks, Inc.
|
| | 8 |
|
< 0.001 | 2 | 9 | narginchk(2,3);
|
< 0.001 | 2 | 10 | objQueried = varargin{1};
|
< 0.001 | 2 | 11 | propName = varargin{2};
|
| | 12 |
|
< 0.001 | 2 | 13 | switch nargin
|
< 0.001 | 2 | 14 | case 2
|
< 0.001 | 2 | 15 | try % size may be overloaded by the object and lead to error here
|
< 0.001 | 2 | 16 | valid = false(size(objQueried));
|
| | 17 | catch % return FALSE when SIZE is overloaded to not return numbers
|
| | 18 | valid = false;
|
| | 19 | return;
|
| | 20 | end
|
| | 21 |
|
< 0.001 | 2 | 22 | if numel(objQueried) == 1
|
0.002 | 2 | 23 | valid = hasProp(objQueried, propName);
|
| | 24 | else
|
| | 25 | % Use for-loop: input may not support ARRAYFUN (e.g. function_handle)
|
| | 26 | for i = 1:numel(objQueried)
|
| | 27 | valid(i) = hasProp(objQueried(i), propName);
|
| | 28 | end
|
< 0.001 | 2 | 29 | end
|
| | 30 | case 3 % ISPROP for class - package and class name
|
| | 31 | try
|
| | 32 | p = findprop(findclass(findpackage(objQueried),propName),varargin{3});
|
| | 33 | valid = ~isempty(p) && strcmpi(p.Name,varargin{3});
|
| | 34 | catch
|
| | 35 | valid = false;
|
| | 36 | end
|
| | 37 | otherwise
|
| | 38 | assert(false); % Number of inputs should only be the above values
|
| | 39 | end
|
< 0.001 | 2 | 40 | end
|
Other subfunctions in this file are not included in this listing.