What Is the Definition of Scalar Structure?

73 ビュー (過去 30 日間)
Rightia Rollmann
Rightia Rollmann 2017 年 3 月 5 日
コメント済み: Steven Lord 2018 年 7 月 19 日
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 Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by