Check if object's property is empty

조회 수: 27 (최근 30일)
Monika Jaskolka
Monika Jaskolka 2022년 2월 20일
답변: Fangjun Jiang 2022년 3월 23일
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
Henry Barth
Henry Barth 2022년 3월 23일
편집: Henry Barth 2022년 3월 23일
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
Adam Danz
Adam Danz 2022년 3월 23일
I second Rik's advice.

댓글을 달려면 로그인하십시오.

답변 (1개)

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

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by