首页 > 其他 > 详细

Matlab - 将字符串作为代码执行

时间:2017-09-23 12:06:25      阅读:267      评论:0      收藏:0      [点我收藏+]

使用eval()函数将字符串作为代码执行;

配合num2str()函数和循环结构,可访问按规律排列的文件。

 

>> help eval

eval Execute MATLAB expression in text.

% eval 将字符作为MATLAB代码执行;

eval(EXPRESSION) evaluates the MATLAB code in the character vector
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
 
See also feval, evalin, assignin, evalc.
 
Reference page for eval
Other functions named eval

Matlab - 将字符串作为代码执行

原文:http://www.cnblogs.com/Jian-thinker/p/7580580.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!