How do I make a function accept structure and fields as separate inputs?
Afficher commentaires plus anciens
I have a structure that is organised something like this:
Subject(index).DataType.DataSubType.means
And I want to run a custom-written function on it.
Part of the function is to loop through all the elements in the structure:
for index = 1:20
%do something to Subject(index).DataType.DataSubType.means
end
I would also like this function to work on different, similarly organised data, e.g. Differentstructure(index).DataType.DataSubType.SDs. Thus I want to be able to give the overall name of the structure ('Subject') and the particular field ('DataType.DataSubType.means') as separate inputs to the function.
Is there a way to do this? I haven't been able to find one. Eval doesn't work, and I'm aware it isn't good practice anyway. If not, how should I organise my function to do this?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!