what does 1x8 struct mean?

조회 수: 9 (최근 30일)
Leonardo Wayne
Leonardo Wayne 2016년 3월 2일
답변: Orion 2016년 3월 2일
what does the notation of size for struct means ? e.g. 1x8 struct with 3 fields

답변 (2개)

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

Orion
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

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by