what does 1x8 struct mean?
3 views (last 30 days)
Show older comments
what does the notation of size for struct means ? e.g. 1x8 struct with 3 fields
0 Comments
Answers (2)
dpb
on 2 Mar 2016
It's an array of structures oriented as a row vector of those structures, each entry of which has three fields. Simple example is structure returned by dir...
>> d=dir('*.csv') % get a directory structure for local .csv files...
d =
31x1 struct array with fields:
name
date
bytes
isdir
datenum
>> d=d.' % turn it from column- to row-oriented (not that it really makes much difference)
d =
1x31 struct array with fields:
name
date
bytes
isdir
datenum
>> d(23).name % address a particular entry and field in the array
ans =
long.csv
>>
0 Comments
Orion
on 2 Mar 2016
You can see it as an array of structure.
if you define a structure such as
s.a = 1;
s.b = 2;
s is actually a 1x1 struct. you can access the fields either with the syntax s.a or s(1).a .
but you can create an array of structure :
s(1).a = 1;
s(1).b = 2;
s(2).a = 3;
s(2).b = 4;
Now s is a 1x2 struct. you can access the 'a' field of the ith component withe syntax s(i).a
0 Comments
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!