Concatenate identical structures

Version 1.0.0 (1,41 ko) par thitch
Concatenate field data from two MATLAB structures with identical fields.
11 téléchargements
Mise à jour 19 jan. 2022

Afficher la licence

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.
Compatibilité avec les versions de MATLAB
Créé avec R2018b
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Publié le Notes de version
1.0.0