Wanted to check if a variable exits or not within 'nirsinfo'.

조회 수: 2 (최근 30일)
CalebJones
CalebJones 2019년 10월 22일
답변: Sahithi Kanumarlapudi 2019년 11월 4일
if exist(nirsInfo.RawDataInfo.checking,'var') == 1
disp("file exists");
else
disp("doesnt");
end
Here since the .checking doesn't exsist it throwing Reference to non-existent field 'checking' error.
  댓글 수: 1
CalebJones
CalebJones 2019년 10월 22일
편집: CalebJones 2019년 10월 22일
if isfield(nirsInfo.RawDataInfo,'checking') is the correct syntax

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

답변 (1개)

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi 2019년 11월 4일
isfield' can be used to check if a field exists within a structure.
Refer to the following documentation for more information on isfield

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by