How to know if exist an field into a struct?

4 次查看(过去 30 天)
I want a funtion which give me "0" if dosen't exist a field into a struct and "1" if it exist, something like that:
s=struct("field1",val1,"field2",val2,"field3",val3);
exist(s.field1)
=1
exist(s.field5)
=0

采纳的回答

Steven Lord
Steven Lord 2016-4-14
Take a look at isfield.

更多回答(0 个)

类别

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