Find a parameter in a multi-tiered structure

I have a structure setup in the following format: fileName.packetName.parameter.data
Where all the parameters across the multiple packetNames are different. I am looking for a solution to not have to specify the packetName as different software versions have parameters located in other packets (i.e. Var1 is in Packet1 in version 1.0 but it moves to Packet2 in version 1.1)

 Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Oct. de 2023

0 votos

You are perhaps looking for something that MATLAB refers to as "dynamic field names"; https://www.mathworks.com/help/matlab/matlab_prog/generate-field-names-from-variables.html

3 comentarios

Matthew
Matthew el 16 de Oct. de 2023
This seems close but not quite what I'm looking for, unless I'm missing a usecase from there. I'm basically looking to skip a level of the structure. In the same terms as my original post, I have a structure in the format of name.Packet0, name.Packet1, name.Packet2, and name.Packet3. Each of these packets are also structures, which each contain 50 or so unique variables (so about 200 unique variables) but I'm looking for a way to not specify the Packet#.
The linked guide looks to be a way to dynamically create/call a structure but in my scenario I would still need to find which packet contains my desired variable.
Walter Roberson
Walter Roberson el 16 de Oct. de 2023
You cannot "skip" structure levels.
The facilities you should be looking at are fieldnames and structfun
Matthew
Matthew el 16 de Oct. de 2023
Looks like that'll do, thank you much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2018b

Etiquetas

Preguntada:

el 13 de Oct. de 2023

Comentada:

el 16 de Oct. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by