FreeMat: ISFIELD Test for Existence of a Structure Field

FreeMat

- Main Page
- Related Pages

ISFIELD Test for Existence of a Structure Field

Section: Inspection Functions

# Usage

Given a structure array, tests to see if that structure array contains a field with the given name. The syntax for its use is

      y = isfield(x,field)

and returns a logical `1` if `x` has a field with the name `field` and a logical `0` if not. It also returns a logical `0` if the argument `x` is not a structure array.

# Example

Here we define a simple struct, and then test for some fields

    --> a.foo = 32

    a =
        foo: 32
    --> a.goo = 64

    a =
        foo: 32
        goo: 64
    --> isfield(a,'goo')

    ans =
     1

    --> isfield(a,'got')

    ans =
     0

    --> isfield(pi,'round')

    ans =
     0