what does 1x8 struct mean?

8 visualizaciones (últimos 30 días)
Leonardo Wayne
Leonardo Wayne el 2 de Mzo. de 2016
Respondida: Orion el 2 de Mzo. de 2016
what does the notation of size for struct means ? e.g. 1x8 struct with 3 fields

Respuestas (2)

dpb
dpb el 2 de Mzo. de 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 el 2 de Mzo. de 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

Categorías

Más información sobre Structures en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by