imat_result/group_by


Purpose

Group results by the values of a specified attribute.

Syntax

out = group_by(r,att)
out = group_by(r,'DataLocation')

Description

GROUP_BY groups an imat_result by the values in the attribute specified and returns the output in a structure. This is useful for grouping results by their DataLocation, for example.

R is an imat_result.

ATT is a string containing the attribute by whose values the imat_result should be grouped. The specified attribute must be one whose type is a string.

OUT is a structure whose fields correspond to the names of the attributes contained in the values of the attribute ATT. Spaces are replaced by underscores (_) so that the structure field names are valid.

Examples

>> r = imat_result(3,'Data',imat_result_dan);
>> r(2).Data = imat_result_danoe;
>> r.name = {'1st' '2nd' '3rd'}

r =
3x1 IMAT_RESULT
Row  Name  DataLocation               ModelType  ResultType
---  ----  -------------------------  ---------  ------------
  1  1st   Data At Nodes              Unknown    User defined
  2  2nd   Data At Nodes On Elements  Unknown    User defined
  3  3rd   Data At Nodes              Unknown    User defined

>> out = group_by(r,'DataLocation');

out =
                Data_At_Nodes: [2x1 imat_result]
    Data_At_Nodes_On_Elements: [1x1 imat_result]