Matlab中输入help eval
eval(EXPRESSION) evaluates the MATLAB code in the string EXPRESSION.
[OUTPUT1,...,OUTPUTN] = eval(EXPRESSION) returns output from EXPRESSION
in the specified variables.
Example: Interactively request the name of a matrix to plot.
expression = input('Enter the name of a matrix: ','s');
if (exist(expression,'var'))
plot(eval(expression))
eval(EXPRESSION) evaluates the MATLAB code in the string EXPRESSION.
[OUTPUT1,...,OUTPUTN] = eval(EXPRESSION) returns output from EXPRESSION
in the specified variables.
Example: Interactively request the name of a matrix to plot.
expression = input('Enter the name of a matrix: ','s');
if (exist(expression,'var'))
plot(eval(expression))
end
注释:eval命令是将括号中的字符串表达式当作Matlab命令来执行
例如:在Matlab中,输入a=1,跟eval('a=1')是等价的
本文详细介绍了Matlab中eval命令的使用方法及应用场景,通过示例展示了如何利用eval命令实现字符串表达式的动态执行,适用于需要动态构建和执行Matlab代码的情况。
3431

被折叠的 条评论
为什么被折叠?



