Concatenate identical structures

Concatenate field data from two MATLAB structures with identical fields.

You are now following this Submission

Given two MATLAB structures with identical sets of fields, the function catStruct() combines them into a single struct containing the combined field data. For example, given
struct_1.a = [2x10 double]
struct_1.b = [3x3x100 double]
struct_2.a = [2x5 double]
struct_2.b = [3x3x50 double]
this function will return
struct_3 = catStruct(struct_1, struct_2)
struct_3.a = [2x15 double]
struct_3.b = [3x3x150 double]
catStruct() recursively, in case your structure fields are themselves structures. This function is useful, for example, in the context of combining multiple sets of test data to plot aggregate results. Useful modifications would include:
  • updating your own concatenation rules, for example line 8 of catField(),
  • updating the argument of catStruct() to accept a struct array, for example.

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0