当前位置:网站首页>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分)
- 无重复字符的最长子串
- Unix Environment Programming Chapter 15 15.3 Functions popen and pclose
- shell脚本实战(第2版)/人民邮电出版社 脚本1 在PATH中查找程序
- unix系统编程 第十五章 15.2管道
- ThreadLocal及其内存泄露分析
- pytorch widedeep文档
- Unix Environment Programming Chapter 15 15.7 Message Queuing
- 研发需求的验收标准应该怎么写? | 敏捷实践
- unix环境编程 第十五章 15.10 POSIX信号量
猜你喜欢
随机推荐
pip常见命令和更改源文件
遇到恶意退款不用怕,App 内购买项目的退款通知现已可用
依赖注入(Dependency Injection)框架是如何实现的
1003 Emergency (25分)
sublime记录
MNIST机器学习入门
备战金三银四:如何成功拿到阿里offer(经历+面试题+如何准备)
For versions corresponding to tensorflow and numpy, report FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecate
How tall is the B+ tree of the MySQL index?
1009 Product of Polynomials C语言多项式乘积(25分)
unix环境编程 第十四章 14.4 I/O多路转接
华为VRRP+MSTP联动接口检测实验案例
MySQL外键在数据库中的作用
Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
非科班毕业生,五面阿里:四轮技术面+HR一面已拿offer
Quartz的理解
Beauty Values
PoseNet: A Convolutional Network for Real-Time 6-DOF Camera Relocalization Paper Reading
numpy库中的函数 bincount() where() diag() all()
无重复字符的最长子串