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!