Why is the Matlab function “feval” needed?

后端 未结 3 1381
灰色年华
灰色年华 2020-12-31 02:28

A function handle can be used to call a function, e.g.

f = @sin;
val = f(1.0);

so why is fev

3条回答
  •  生来不讨喜
    2020-12-31 02:52

    For feval, the first argument can be a quoted string, giving you more flexibility than a function handle. You could do things like having functions with a base name followed by an index as in fn1, fn2, fn3, and then invoke these dynamically using feval(['fn', num2str(k)], x, y, z);.

提交回复
热议问题