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

2 visualizaciones (últimos 30 días)
CalebJones
CalebJones el 22 de Oct. de 2019
Respondida: Sahithi Kanumarlapudi el 4 de Nov. de 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 comentario
CalebJones
CalebJones el 22 de Oct. de 2019
Editada: CalebJones el 22 de Oct. de 2019
if isfield(nirsInfo.RawDataInfo,'checking') is the correct syntax

Iniciar sesión para comentar.

Respuestas (1)

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

Categorías

Más información sobre Structures en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by