Clear Filters
Clear Filters

Check if object's property is empty

18 views (last 30 days)
Monika Jaskolka
Monika Jaskolka on 20 Feb 2022
Answered: Fangjun Jiang on 23 Mar 2022
I have an xmlcomp.Edits object that was created when performing a comparison via the command
root = slxmlcomp.compare(...)
In this case, an xmlcomp.Edits object was created (see attached file) but all properties are empty. However, I don't know how to check if the properties are empty so I can catch the error that occurs when I try to access the properties. Is there a command to use when the object's properties are empty?
  14 Comments
Henry Barth
Henry Barth on 23 Mar 2022
Edited: Henry Barth on 23 Mar 2022
if you want a function for your check, you could implement it for your needs like this:
function ispropOut = SOME_FUNCTION(objIn,nameIn)
ispropOut = false(size(objIn));
for nObjRow = 1:size(objIn,1)
for nObjCol = 1:size(objIn,2)
try
objIn(nObjRow,nObjCol).(nameIn);
ispropOut(nObjRow,nObjCol) = true;
catch
end
end
end
end

Sign in to comment.

Answers (1)

Fangjun Jiang
Fangjun Jiang on 23 Mar 2022
Might this help?
>> EmptyRoot=xmlcomp.Edits('')
EmptyRoot =
Edits with no properties.
>> isequal(root,EmptyRoot)
ans =
logical
1
>> isequal(root2,EmptyRoot)
ans =
logical
0

Categories

Find more on Debugging and Analysis in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!