feval
类: matlab.mex.MexHost
命名空间: matlab.mex
在 MEX 主机进程中计算 C++ MEX 函数
语法
[result1,...,resultN] = feval(mexHost,mexFunctionName,input1,...,inputM)
说明
[
在 MEX 主机进程中计算指定的 C++ MEX 函数,并返回结果。您可以在单一主机进程中运行多个 C++ MEX 函数。result1,...,resultN
] = feval(mexHost
,mexFunctionName
,input1,...,inputM
)
输入参数
mexHost
— MEX 主机进程
matlab.mex.MexHost
对象
MEX 主机进程,指定为 matlab.mex.MexHost
对象。使用 mexhost
函数创建 MEX 主机进程。
mexFunctionName
— 要执行的 C++ MEX 函数的名称
字符向量 | 字符串标量
要执行的 C++ MEX 函数的名称,指定为字符向量或字符串标量。
示例: "myMexFunction"
数据类型: char
| string
input1,...,inputM
— C++ MEX 函数的输入
取决于函数
C++ MEX 函数的输入。可以指定为输入的值的个数和类型取决于 C++ MEX 函数。
输出参量
result1,...,resultN
— C++ MEX 函数的计算结果
取决于函数
C++ MEX 函数的计算结果。返回值的个数和类型取决于 C++ MEX 函数。
示例
在进程外运行 MEX 函数
创建一个 MEX 主机进程,并在该进程中运行 C++ MEX 函数。
arrayProduct.cpp
C++ MEX 文件包含一个函数的源代码,该函数将数组乘以标量输入并返回生成的数组。打开此文件,并将其保存在 MATLAB® 路径上。使用 mex
命令编译 C++ MEX 源文件。按照编译 C++ MEX 程序中的说明设置 MEX 编译。
mex arrayProduct.cpp
创建一个主机进程。mexhost
函数返回 matlab.mex.MexHost
对象。
mh = mexhost;
使用 matlab.mex.MexHost
对象的 feval
方法在主机进程中计算 C++ MEX 函数。
result = feval(mh,"arrayProduct",10,[2,4,6,8])
result = 20 40 60 80
版本历史记录
在 R2019a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)