isstruct

Tests whether a value is a struct.

Category: Language Fundamentals > Data Types

Syntax

tf = isstruct(A)

Returns true if A is a structure array.

Description

A struct and a struct array both count. Tables, objects and cell arrays do not, even though a table can be converted with table2struct. Use isfield afterwards to see which fields exist.

Input arguments

A
Any value.

Output arguments

tf
Logical scalar.

Example

Structs and look-alikes

isstruct(struct('a', 1))
isstruct(struct('a', {1, 2}))
isstruct({1})
isstruct(table(1))
Output
ans = logical
   1
ans = logical
   1
ans = logical
   0
ans = logical
   0

See also

isfield struct fieldnames iscell