what does 1x8 struct mean?
2 次查看(过去 30 天)
显示 更早的评论
what does the notation of size for struct means ? e.g. 1x8 struct with 3 fields
0 个评论
回答(2 个)
dpb
2016-3-2
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 个评论
Orion
2016-3-2
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!