groupStruct

Group a struct-array by the nominal values for specified fields.
166 téléchargements
Mise à jour 29 mai 2012

Afficher la licence

Group a struct-array by the nominal values (which will be created) for the fields you specify. Returns a grouped struct, a cell-array containing the different groups, a cell-array with the nominal values that were used, a cell-array with the fields that were used, and a cell-array with the indexes from the original struct corresponding to the one used in the groups.
If you for instance have a struct-array with experimental data with different inclinations (PHI) and velocities (V) you can use the following example to group the experiments by the nominal values for the fields PHI and V:

%Create some artificial experimental data
s=struct;
s.PHI=0;
s.V=1.1;
s(end+1).PHI=1;
s(end).V=1.082;
s(end+1).PHI=0;
s(end).V=1.084;
s(end+1).PHI=1;
s(end).V=0.61;
s(end+1).PHI=1;
s(end).V=0.58;
s(end+1).PHI=0;
s(end).V=0.598;
s(end+1).PHI=0;
s(end).V=1.12;

%Group the struct by PHI and V, using 5% as tolerance when creating nominal values for both PHI and V.
[sOut,groups,nomsOut,ids,inds] = groupStruct( s, {'PHI','V'}, [0.05,0.05] );

Requires the 'nominal' function, and the 'getarg' function.

Citation pour cette source

Ivar Eskerud Smith (2024). groupStruct (https://www.mathworks.com/matlabcentral/fileexchange/36897-groupstruct), MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2012a
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Structures dans Help Center et MATLAB Answers

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.0