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

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 Commento

CalebJones
CalebJones il 22 Ott 2019
Modificato: CalebJones il 22 Ott 2019
if isfield(nirsInfo.RawDataInfo,'checking') is the correct syntax

Accedi per commentare.

Risposte (1)

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

Categorie

Richiesto:

il 22 Ott 2019

Community Treasure Hunt

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

Start Hunting!

Translated by