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

1 Ansicht (letzte 30 Tage)
CalebJones
CalebJones am 22 Okt. 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 Kommentar
CalebJones
CalebJones am 22 Okt. 2019
Bearbeitet: CalebJones am 22 Okt. 2019
if isfield(nirsInfo.RawDataInfo,'checking') is the correct syntax

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi am 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

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by