我可以在Matlab命令中执行以下想法吗? 假设
a = 'c1Tl';
class(a)将返回单元格。
如何将a的内容用作我可以做的单元格变量
c1Tl = 3;
我尝试使用
sym(a) = 3;
将变量分配给'a'的内容,但这不是我的目的。 请帮忙解决我的问题! 谢谢!
答案 0 :(得分:0)
最好的方法是使用struct数据类型。你会做这样的事情:
a = {'c1Tl'};
%Lets make a struct called data which will store the values
data.(a{1}) = 3; % The a{1} accesses the string stored in a and uses it to make a field in the structure data
%To access your data, now you can use
data.c1Tl