Questions tagged «matlab-struct»

4
在MATLAB中遍历结构字段名
我的问题很容易概括为:“为什么以下内容不起作用?” teststruct = struct('a',3,'b',5,'c',9) fields = fieldnames(teststruct) for i=1:numel(fields) fields(i) teststruct.(fields(i)) end 输出: ans = 'a' ??? Argument to dynamic structure reference must evaluate to a valid field name. 特别是因为teststruct.('a') 确实有效。并fields(i)打印出来ans = 'a'。 我无法解决这个问题。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.