Navigation

Operators and Keywords

Function List:

C++ API

test_struct.m File Reference


Functions

id a ()
 !assert (iscell(c)&&strcmp(c{1},"a"))
id b ()
 !assert (iscell(c)&&strcmp(c{1},"b"))
id fieldnames ()
 !fail ("fieldnames (s, 1)","Invalid call to fieldnames.*")
id aaa ()
 !assert (isfield(s,"a"))
 !assert (!(isfield(s,"b")))
id isfield ()
 !fail ("isfield (s, 'a', 3);","Invalid call to isfield.*")
isfield(1,"m" assert ()
 !assert (isfield(s, 2)==0)
 !assert (isstruct(s))
 !assert (isstruct(s.a))
id isstruct ()
 !fail ("isstruct (s, 1)","Invalid call to isstruct.*")
 !a (2).c(3)++
 !assert (a(2).c,[4, 5, 7])
 !assert (a, struct("x",{1, 3}))
 !assert ({a(1:2).x},{1, 3})
 !assert (a(2).value(2, 3).name,"f")
 !b (3, 1).value
 !assert (size(b),[3, 3])
 !assert (b(3, 1).value(1, 3).name,"ccc")
!test !c (4, 4, 4, 4).name
 !c (3, 3, 3, 3).value
 !assert (c(2, 2, 2, 2), struct("name",[],"value",[]))
 !assert (length(find([c.value]==1)), 17)
 !assert (length(find([c.value])), 17)
 !c (1, 2, 3, 4).value
 !assert ([d{4, 4, 4, 4}, d{1, 2, 3, 4}, d{3, 3, 3, 3}],%![3, 2, 1])
 b (2, 1:3).value]
 !a (2:3).x(2)
!error< Index exceeds matrix
dimension > 
!a (1).x.x
 !c ([1, 3], 2,:,[3, 4]).value
 !assert (a.b.c.b, struct("a", 1))
 !assert (a.b.e.b.d.c, struct("a", 1,"b", 2))
 !assert (a.b.b.b, struct("c", 1))
 !assert (a.b.c.b.b.c.b.b.c.b, struct("c", 1))
 !assert (a.m.c.b.m.i.j.k.l, struct("b", 1))
 !s (3).foo
 !assert (s(3), struct("foo", 42))
 !s (7)

Variables

 !c = fieldnames (s)
!s a = 2
!test !a = struct("c", {[1, 2, 3], [4, 5, 6], [7, 8, 9]})
 !test [a(1:2).x] = deal (1, 3)
!test !b = struct ("name", {"a", "b", "c"; "d", "e", "f"}, "value", 100)
 name = deal("aaa", "ddd", "ccc", "fff")
 __pad0__
 value = deal (1)
 !d = reshape ({c.value}, size(c))
 !error< a cs-list cannot be further indexed > [a(1:3).x] = deal ([1, 5], [3, 7], [8, 9])
 !error< can't perform indexing operations for cs-list type > [a(1:3).x] = deal (10, 11) deal ([1, 5], [3, 7], [8, 9])
!a b = a
!a b c = a
!b d = 3
!c e = 4
!function aa = do_nest (a)
 !aa = a
!b f g h = a
!b i j k l = a
!a m = b
!test !s = resize(struct(),3,2)

Function Documentation

!error<Index exceeds matrix dimension> !a (  ) 

!a ( 2:3   ) 

!a (  ) 

!assert ( s(3)  ,
struct("foo", 42)   
)

!assert ( a.m.c.b.m.i.j.k.  l,
struct("b", 1)   
)

!assert ( a.b.c.b.b.c.b.b.c.  b,
struct("c", 1)   
)

!assert ( a.b.b.  b,
struct("c", 1)   
)

!assert ( a.b.e.b.d.  c,
struct("a", 1,"b", 2)   
)

!assert ( a.b.c.  b,
struct("a", 1)   
)

!assert ( %!  [3, 2, 1]  ) 

!assert ( length(find([c.value]))  ,
17   
)

!assert ( length(find([c.value]==1))  ,
17   
)

!assert ( c(2, 2, 2, 2)  ,
struct("name",[],"value",[])   
)

!assert ( b(3, 1).value(1, 3).  name,
"ccc"   
)

!assert ( size(b)   ) 

!assert ( a(2).value(2, 3).  name,
"f"   
)

!assert (  ) 

!assert ( ,
struct("x",{1, 3})   
)

!assert ( a(2).  c  ) 

!assert ( isstruct(s.a)   ) 

!assert ( isstruct(s)   ) 

!assert ( isfield(s, 2)  = =0  ) 

!assert ( isfield(s,"b")  ) 

!assert ( isfield(s,"a")   ) 

!assert ( iscell(c)&&strcmp(c{1},"b")   ) 

!assert ( iscell(c)&&strcmp(c{1},"a")   ) 

!b ( ,
 
)

!c ( ,
 
)

!c ( ,
,
,
 
)

!c ( ,
,
,
 
)

!test !c ( ,
,
,
 
)

!fail ( "isstruct (s, 1)"  ,
"Invalid call to isstruct.*"   
)

!fail ( "isfield (s, 'a', 3);"  ,
"Invalid call to isfield.*"   
)

!fail ( "fieldnames (s, 1)"  ,
"Invalid call to fieldnames.*"   
)

!s (  ) 

!s (  ) 

id a (  )  [virtual]

id aaa (  )  [virtual]

isfield (1, "m" assert (  )  [virtual]

b ( ,
1:3   
)

Type Constraints

id b (  )  [virtual]

fieldnames (  )  [virtual]

id isfield (  )  [virtual]

isstruct (  )  [virtual]


Variable Documentation

!a = struct("c", {[1, 2, 3], [4, 5, 6], [7, 8, 9]})

!aa = a

!test !b = struct ("name", {"a", "b", "c"; "d", "e", "f"}, "value", 100)

!c = fieldnames (s)

!d = reshape ({c.value}, size(c))

!error< a cs-list cannot be further indexed >[a(1:3).x] = deal ([1, 5], [3, 7], [8, 9])

!error< can't perform indexing operations for cs-list type >[a(1:3).x] = deal (10, 11) deal ([1, 5], [3, 7], [8, 9])

!error<Index exceeds matrix dimension> !s = resize(struct(),3,2)

!test[a(1:2).x] = deal (1, 3)

!test ! a a = 2

!function aa = do_nest (a)

! a m c b = a

! b c = a

! c d = 3

! b d e = 4

! b f g h = a

! b i j k l = a

! a m = b

name = deal("aaa", "ddd", "ccc", "fff")

value = deal (1)