Do you ever make use of non-uniform arrays of structures?
조회 수: 1 (최근 30일)
이전 댓글 표시
Loren explained in the following comment on her blog that certain vectorized struct assignment syntax is not currently allowed because there is no guarantee that arrays of structs are uniform: http://blogs.mathworks.com/loren/2007/04/19/vectorizing-access-to-an-array-of-structures/#comment-16189
She proposes adding a new 'uniform' struct data type to permit this. Personally I'd rather enable the syntax for existing structs and error if one tries the syntax on a non-uniform array of structs, because I've never had the need to use non-uniform struct arrays as a data structure in my programming. Have you?
댓글 수: 0
답변 (2개)
Jan
2013년 2월 20일
Yes, I use non-uniform structs. For a motion analysis I store different measurements in a struct array and some of the measurements contain an EMG measurement, and some don't. But of course, I do not try to apply a vectorized access to the subfields (because this would fail). So I agree that allowing this kind of access for the current structs should be valid, when for non-uniform data an error is thrown.
댓글 수: 0
Sean de Wolski
2013년 2월 20일
편집: Sean de Wolski
2013년 2월 20일
When you save a figure, it is internally stored as a *.mat file containing a scalar structure.
If you dig into this for a fancy figure, there can many instances of non-uniformity amongst the various children and their properties (since the children are not necessarily the same class). E.g:
S = load('complicatedFigure.mat'); %rename from complicatedFigure.fig
S.hgS_070000.children.children.properties
As for me: never used 'em.
댓글 수: 2
Sean de Wolski
2013년 2월 20일
The parent is the scalar structure with n fields:
S.hgS_070000
ans =
type: 'figure'
handle: 1
properties: [1x1 struct]
children: [1x1 struct]
special: []
Now digging into children, which is also scalar:
S.hgS_070000.children
ans =
type: 'axes'
handle: 174.0011
properties: [1x1 struct]
children: [4x1 struct]
special: [4x1 double]
We see the non-scalar ones come out of the woodwork. Now, digging into the children's properties (which are different classes!), we see the non-uniformity:
S.hgS_070000.children.children.properties
ans =
CData: [49x49 double]
EdgeColor: [0 0 0]
XData: [49x49 double]
YData: [49x49 double]
ZData: [49x49 double]
ApplicationData: [1x1 struct]
XDataMode: 'manual'
XDataSource: ''
YDataMode: 'manual'
YDataSource: ''
CDataMode: 'auto'
CDataSource: ''
ZDataSource: ''
ans =
Units: 'data'
FontUnits: 'points'
BackgroundColor: 'none'
Color: [0 0 0]
DisplayName: ''
EdgeColor: 'none'
EraseMode: 'normal'
DVIMode: 'auto'
FontAngle: 'normal'
FontName: 'Helvetica'
FontSize: 10
FontWeight: 'normal'
HorizontalAlignment: 'left'
LineStyle: '-'
LineWidth: 0.5000
Margin: 2
Position: [-27.6849 -38.6747 53.3734]
Rotation: 0
String: 'x'
Interpreter: 'tex'
VerticalAlignment: 'top'
ButtonDownFcn: []
CreateFcn: []
DeleteFcn: []
BusyAction: 'queue'
HandleVisibility: 'off'
HelpTopicKey: ''
HitTest: 'on'
Interruptible: 'on'
SelectionHighlight: 'on'
Serializable: 'on'
Tag: ''
UserData: []
ApplicationData: [1x1 struct]
Visible: 'on'
XLimInclude: 'on'
YLimInclude: 'on'
ZLimInclude: 'on'
CLimInclude: 'on'
ALimInclude: 'on'
IncludeRenderer: 'on'
Clipping: 'off'
i_CachedPosition: [-27.6849 -38.6747 53.3734]
ans =
Units: 'data'
FontUnits: 'points'
BackgroundColor: 'none'
Color: [0 0 0]
DisplayName: ''
EdgeColor: 'none'
EraseMode: 'normal'
DVIMode: 'auto'
FontAngle: 'normal'
FontName: 'Helvetica'
FontSize: 10
FontWeight: 'normal'
HorizontalAlignment: 'right'
LineStyle: '-'
LineWidth: 0.5000
Margin: 2
Position: [-30.8417 -36.1657 53.6635]
Rotation: 0
String: 'y'
Interpreter: 'tex'
VerticalAlignment: 'top'
ButtonDownFcn: []
CreateFcn: []
DeleteFcn: []
BusyAction: 'queue'
HandleVisibility: 'off'
HelpTopicKey: ''
HitTest: 'on'
Interruptible: 'on'
SelectionHighlight: 'on'
Serializable: 'on'
Tag: ''
UserData: []
ApplicationData: [1x1 struct]
Visible: 'on'
XLimInclude: 'on'
YLimInclude: 'on'
ZLimInclude: 'on'
CLimInclude: 'on'
ALimInclude: 'on'
IncludeRenderer: 'on'
Clipping: 'off'
i_CachedPosition: [-30.8417 -36.1657 53.6635]
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!