what does 1x8 struct mean?

6 views (last 30 days)
Leonardo Wayne
Leonardo Wayne on 2 Mar 2016
Answered: Orion on 2 Mar 2016
what does the notation of size for struct means ? e.g. 1x8 struct with 3 fields

Answers (2)

dpb
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
>>

Orion
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

Categories

Find more on Structures in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!