当前位置:网站首页>matlab fcnchk 函数用法
matlab fcnchk 函数用法
2022-08-09 10:52:00 【1nsights】
fcnchk will not accept string expressions for FUN in a future release. Use anonymous functions for FUN instead.
fcnchk函数将会在以后的版本中删除,以后用匿名函数代替
fcnchk(FUN,...) returns an inline object based on FUN if FUN
is a string containing parentheses, variables, and math
operators. fcnchk simply returns FUN if FUN is a function handle,
or a MATLAB object with an feval method (such as an inline object).
If FUN is a string name of a function (e.g. 'sin'), fcnchk returns a
function handle to that function.
fcnchk is a helper function for FMINBND, FMINSEARCH, FZERO, etc. so they
can compute with string expressions in addition to functions.
fcnchk(FUN,...,'vectorized') processes the string (e.g., replacing
'*' with '.*') to produce a vectorized function.
When FUN contains an expression then fcnchk(FUN,...) is the same as
INLINE(FUN,...) except that the optional trailing argument 'vectorized'
can be used to produce a vectorized function.
[F,ERR] = fcnchk(...) returns a struct array ERR. This struct is empty
if F was constructed successfully. ERR can be used with ERROR to throw
an appropriate error message if F was not constructed successfully.
简单点来说,如果将字符串传递给fcnchk函数,函数会返回inline函数(前提是这个字符串代表的函数你以经定义了)
例如我定义了一个矩形函数:
function z = rect(x)
x= abs(x);
z = (x<1/2)*1.0 ;
z(find(x==1/2)) = 0.5;
end
上面的函数是一维的,如果我想定义一个二维的矩形函数怎么办呢?
我可以将字符串rect(x).*rect(y)
传递到fcnchk
函数里,会返回一个定义好了的inline函数func
,可以理解为定义好了的函数句柄,
fun = 'rect(x).*rect(y)'
func = fcnchk(fun);
调用func函数,X,Y是函数的坐标
f = feval(func,X,Y);
如果想要指定输入参数的情况下,例如定义矩形函数的门宽,rect(x/w).*rect(y/w)
,
可以采用下面的形式
fun = 'rect(x/w).*rect(y/w)'
func = inline(fun,'x','y','w');
不过这个函数快要退出历史舞台了,还是去学匿名函数的用法吧
看到一个不错的参考资料,需要的朋友可以去看下:
http://pages.cs.wisc.edu/~cs310-1/modules/Programming/_More%20Advanced%20Functions/fcnchk%20Function/TopicDiscussion.html
觉得帮到您的朋友请赏个赞呗!
边栏推荐
- 1005 Spell It Right (20分)
- 1008 Elevator (20分)
- 获取指定年度所有周的工具类
- Oracle数据库:for update 和for update nowait的区别
- MySQL查询性能优化七种武器之索引潜水
- Database connection operations for MySQL and MyEclipse
- activemq 消息持久化
- Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
- electron 应用开发优秀实践
- 支付宝小程序的接入
猜你喜欢
随机推荐
threejs+shader 曲线点运动,飞线运动
Unix Environment Programming Chapter 14 14.4 I/O Multiplexing
PoseNet: A Convolutional Network for Real-Time 6-DOF Camera Relocalization论文阅读
jvm-类加载系统
商业技术解决方案与高阶技术专题 - 数据可视化专题
通过Doc在MySQL数据库中建表
tensor.eq() tensor.item() tensor.argmax()
RPN principle in faster-rcnn
Unix Environment Programming Chapter 15 15.7 Message Queuing
MySQL外键在数据库中的作用
electron 应用开发优秀实践
[Error record] Solve the problem that ASRock J3455-ITX cannot be turned on without a monitor plugged in
OpenSSF的开源软件风险评估工具:Scorecards
Solve 1. tensorflow runs using CPU but not GPU 2. GPU version number in tensorflow environment 3. Correspondence between tensorflow and cuda and cudnn versions 4. Check cuda and cudnn versions
Solve the ali cloud oss - the original 】 【 exe double-click response can't open, to provide a solution
解决1.tensorflow运行使用CPU不使用GPU 2.tensorflow环境下的GPU版本号 3.tensorflow和cuda以及cudnn版本对应问题 4.查看cuda和cudnn版本
获取指定年度所有周的工具类
sublime记录
PoseNet: A Convolutional Network for Real-Time 6-DOF Camera Relocalization Paper Reading
性能测试(05)-表达式和业务关联-json关联