check if a variable in a structure exist

Hello, I must check if the variable handles.Y2 exists in the structure handles(I work with gui). Using exist gives me 0 although it exist in the structure thanks

 Akzeptierte Antwort

dpb
dpb am 16 Apr. 2014

12 Stimmen

isfield(handles,'Y2')
doc isfield % for details
help struct % for reminder on structures

Weitere Antworten (1)

Sara
Sara am 16 Apr. 2014

1 Stimme

Use:
ispresent = isfield(handles,'Y2')
See
help isfield
for more infos.

Kategorien

Gefragt:

am 16 Apr. 2014

Kommentiert:

am 16 Apr. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by