check if a variable in a structure exist

175 次查看(过去 30 天)
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

采纳的回答

dpb
dpb 2014-4-16
isfield(handles,'Y2')
doc isfield % for details
help struct % for reminder on structures

更多回答(1 个)

Sara
Sara 2014-4-16
Use:
ispresent = isfield(handles,'Y2')
See
help isfield
for more infos.

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by