MATLAB Answers

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

3 views (last 30 days)
CalebJones
CalebJones on 22 Oct 2019
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 Comment

CalebJones
CalebJones on 22 Oct 2019
if isfield(nirsInfo.RawDataInfo,'checking') is the correct syntax

Sign in to comment.

Answers (1)

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

  0 Comments

Sign in to comment.

Sign in to answer this question.