Search a Structure Array or Database

Versión 1.0.0 (1,95 KB) por Derek Wood
Searches an entire database structure for the given values or strings, and returns corresponding indices of matching entries
2 descargas
Actualizado 9 jun 2022

Ver licencia

A flexible tool capable of searching a large structure array for matching numerical or character values.
Use case:
[ index_array ] = searchDatabase( dataBase, value, fieldName, modifier)
Required Inputs:
dataBase (struct array or matrix) : struct database to search
value (char or double(value or list) ) : Value/string of fieldname desired to search for or match to
String input is case-insensitive. By default, searches for partial matches to strings.
Optional Inputs:
fieldName (string) : Fieldname of database to searach within (case-insensitive). Default value is an empty string.
If a value is given, will only search for matches in struct fields matching the given fieldName.
modifier (char) : Has 5 allowable values; '=', '~', '>', '<', and '' (empty string). The function varies based on class of value:
If value is a char or string:
1. '': case-insensitive search for value as substring of database field value (default for strings)
2. '=': case-insensitive search for value as exact, full-string match to database field value
3. '~': case-insensitive search for absence of value as substring of database field value
If value is a double:
1. '=': value must be equal to database field value (default value for double)
2. '<': value must be greater than database field value
3. '>': value must be less than database field value
4. '~': value must not be equal to database field value
Output is a list of indices corresponding to the entries in the database matching the criteria supplied by the inputs.
If dataBase is a 2D array (or higher dimensionality), this tool will still return the correct result, however to convert to the full index array you will need to use matlab's ind2sub function.

Citar como

Derek Wood (2024). Search a Structure Array or Database (https://www.mathworks.com/matlabcentral/fileexchange/112915-search-a-structure-array-or-database), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2022a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Etiquetas Añadir etiquetas

Community Treasure Hunt

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

Start Hunting!
Versión Publicado Notas de la versión
1.0.0