help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Test for fieldname in struct


From: Martin Helm
Subject: Test for fieldname in struct
Date: Sun, 01 Apr 2012 22:25:39 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120328 Thunderbird/11.0.1

Maybe I am simply blind, is there an easy way to test if a struct
contains a certain field?
The following looks rather clumsy

st = struct("abc", 1, "def", []);
any(cellfun (@(s) strcmp (s, "def"), fieldnames(st)))
ans =  1
any(cellfun (@(s) strcmp (s, "xyz"), fieldnames(st)))
ans = 0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]