What Is the Definition of Scalar Structure?
69 views (last 30 days)
Show older comments
Rightia Rollmann
on 5 Mar 2017
Commented: Steven Lord
on 19 Jul 2018
What Is the Definition of Scalar Structure?
0 Comments
Accepted Answer
Steven Lord
on 5 Mar 2017
A scalar structure is an array of class struct for which the isscalar function returns true.
6 Comments
Peter Cable
on 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
on 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.
More Answers (0)
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!