Why is the Matlab function “feval” needed?

后端 未结 3 1383
灰色年华
灰色年华 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:59

    Not necessarily always you know what function is supposed to used; there are many examples

    here is a silly example: let, in a text file after each number, different word that can be evaluated as a mathematical function, like, mean, min, max, square are represented, and the task is calculating the result after each like,

    2,square,2,power,4,log,10 ...
    

    and you want to write a program to go through this text and calculate the final result ...

    another example is for example, I want to define a plot function with user input function handle f, so it must be in a way flexible ...

    pfun=@(f,x) plot(f(x))
    

提交回复
热议问题