What Is the Definition of Scalar Structure?

92 次查看(过去 30 天)
What Is the Definition of Scalar Structure?

采纳的回答

Steven Lord
Steven Lord 2017-3-5
A scalar structure is an array of class struct for which the isscalar function returns true.
  6 个评论
Peter Cable
Peter Cable 2018-7-19
@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 2018-7-19
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.

请先登录,再进行评论。

更多回答(0 个)

类别

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