2018/09/03

Matlab: feval() - Call functions with the function name as a string input

To call any Matlab function, use feval() with the function nameas the first input string and the parameters of the function as the other remaining input arguments.

For example, for sayHello.m:

function sayHello(name)

fprintf('Hello %s!\n',name);

Results of the command line with fevel():

>> sayHello('Matlab')
Hello Matlab!
>> feval('sayHello','World')
Hello World!

Reference:

feval() - Evaluation function (MathWorks)

沒有留言:

張貼留言