码迷,mamicode.com
首页 > 其他好文 > 详细

[Matlab] feval使用

时间:2015-06-26 12:34:24      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:

 查看doc feval:
[y1, y2, ...] = feval(fhandle, x1, ..., xn)
[y1, y2, ...] = feval(fname, x1, ..., xn)

 

 [y1, y2, ...] = feval(fhandle, x1, ..., xn) evaluates the function handle, fhandle, using arguments x1 through xn. If the function handle is bound to more than one built-in or .m function, (that is, it represents a set of overloaded functions), then the data type of the arguments x1 through xn determines which function is dispatched to.

 [y1, y2, ...] = feval(fname, x1, ..., xn). If fname is a quoted string containing the name of a function (usually defined within file having a .m file extension), then feval(fname, x1, ..., xn) evaluates that function at the given arguments. The fname parameter must be a simple function name; it cannot contain path information.

意思很清楚,feveal就是把已知数据和符号带入已定义好的函数或函数句柄中,简单理解就是求函数的值用的。

 

例如:

假设需要调用的函数foo定义如下:

  function x=foo(a,b)

  x=a*b; 

若在main函数中用feval调用foo,可以有以下几种方式

1. result=feval(‘foo‘,3,15); 

2. result=feval(@foo,3,16); %这里@foo即句柄

等价于result = x(3,15)。

详细参见: http://www.cnblogs.com/begtostudy/archive/2012/06/27/2565920.html

 

[Matlab] feval使用

标签:

原文地址:http://www.cnblogs.com/jhsx/p/4601780.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!