MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   Matlab变量中的函数名称和参数 (https://www.labfans.com/bbs/showthread.php?t=22584)

poster 2019-12-10 16:49

Matlab变量中的函数名称和参数
 
在我的matlab m文件中,我使用一些逻辑(字符串concat)来构建这样的变量:

c = 'CalcPrediction(1,10)' 这意味着我有一个字符串,它是一个函数和一些参数。我该如何调用该函数?

尝试运行(c)会导致:

>> run(c) ??? Error using ==> run at 71 CalcPrediction(1,10) not found. 注意:如果没有参数,run(c)可以正常工作。例如c ='CalcPrediction';运行(c);


回答:
您要查找的命令是eval()而不是run()



[url=https://stackoverflow.com/questions/421873]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 01:11

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.