【发布时间】:2010-10-07 18:37:12
【问题描述】:
可能的重复:
How to concatenate a number to a variable name in MATLAB?
MATLAB: How can I use a variables value in another variables name?
我想使用函数中给定的其他变量的值来命名变量。 因此,如果我有 x1,x2 的值,我可以将新变量的名称设为:
x_(x1 的值)_(x2 的值) 作为名称。
我已经检查了 eval、num2str、strcat 函数,但到目前为止我还做不到,所以我有一个上面名字的变量,我可以给它赋值。
任何帮助将不胜感激。
【问题讨论】:
-
听起来您应该改用数组。
-
阅读@MatlabDoug 的不良编码实践列表,特别是第 1 点 blogs.mathworks.com/videos/2010/03/08/…
标签: variables matlab naming naming-conventions