What Is the Definition of Scalar Structure?

75 visualizaciones (últimos 30 días)
Rightia Rollmann
Rightia Rollmann el 5 de Mzo. de 2017
Comentada: Steven Lord el 19 de Jul. de 2018
What Is the Definition of Scalar Structure?

Respuesta aceptada

Steven Lord
Steven Lord el 5 de Mzo. de 2017
A scalar structure is an array of class struct for which the isscalar function returns true.
  6 comentarios
Peter Cable
Peter Cable el 19 de Jul. de 2018
@Stephen Cobeldick: how can the size of the structure be independent of how many fields it has? when you add another field, the structure becomes 1*2 and would fail the isscalar test right?
Steven Lord
Steven Lord el 19 de Jul. de 2018
Nope. Adding a file folder to the drawer in a filing cabinet with one drawer doesn't change the fact that the filing cabinet has one drawer. It just means the drawer contains one more folder than it did before. Buying another one-drawer filing cabinet and stacking it on top of the first would change the number of drawers your filing system has available.
The analogy isn't perfect, because "each structure in the array must have the same number of fields and the same field names" and there's no limitation that the drawers in a filing cabinet must have the same number of file folders, but it's useful enough when talking about sizes.
The size of the struct is analogous to the number of drawers in your filing cabinet while the number of fields in your struct array (the length of the cell array returned by calling fieldnames on the struct) is the number of folders inside each drawer.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by