MATLAB: How to find number of objects in a structure

MATLABnumberofobjectsstruct

Hi I'm new to Matlab. I have the following struct array and I want to save the number of objects of struct in a variable. How can I find number of objects? Any help would be appreciated

Best Answer

Let i am creating a structure s below
S = struct('a', 0, 'b', 1, 'c', 2);
Now when i am investigating what is inside of struture i type
>> S
S =
a: 0
b: 1
c: 2
Now i want to access value of its first feild(which is a)
S.a
ans =
0
for value of last feild, type this
S.c
ans =
2
now let's say i want to modify value( new value of 10) of last feild(c) of strutre S , do this
S.c=10
S =
a: 0
b: 1
c: 10
if you want to delete any field of struture S , use this
S.a=[]
S =
a: []
b: 1
c: 10
Tell me if you need to learn more about struture?
Usman