Passing a string to a function
1 回表示 (過去 30 日間)
古いコメントを表示
I have created several structures based on my data using eval. The names of the structures and the names of the fields are stored in seperate arrays and the names can be different depending on the data. How can I pass these strings into a functin such as fieldnames? I keep gettting errors that the input arguments cannot be 'cell' or 'char'. So if the name of my struct is in name(1,1) how can i run fieldnames(name(1,1))
0 件のコメント
採用された回答
Wayne King
2012 年 3 月 20 日
namestruct = 'test';
test = struct('x',randn(100,1),'y',randn(100,1));
namez = fieldnames(eval(namestruct))
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!