How do I make a function accept structure and fields as separate inputs?
古いコメントを表示
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?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!