Filter löschen
Filter löschen

What Is the Definition of Scalar Structure?

86 Ansichten (letzte 30 Tage)
Rightia Rollmann
Rightia Rollmann am 5 Mär. 2017
Kommentiert: Steven Lord am 19 Jul. 2018
What Is the Definition of Scalar Structure?

Akzeptierte Antwort

Steven Lord
Steven Lord am 5 Mär. 2017
A scalar structure is an array of class struct for which the isscalar function returns true.
  6 Kommentare
Peter Cable
Peter Cable am 19 Jul. 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 am 19 Jul. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by