com.mathworks.engine.matlabengine
爪哇类MATLAB作为计算引擎
描述
Thecom.mathworks.engine.matlabengine
课程使用MATLAB®作为Java的计算引擎的过程®。该类提供Java语言和MATLAB之间的接口,使您能够评估Java的MATLAB功能和表达式。
创建
TheMatlabEngine
class provides static methods to start MATLAB and to connect to a shared MATLAB session synchronously or asynchronously. Only these static methods can instantiate this class:
Start MATLAB synchronously —StartMatlab
同步连接到共享MATLAB会话 -ConnectMatlab
Start MATLAB asynchronously —StartMatlabAsync
连接到共享MATLAB会话异步 -ConnectMatlabasync
不支金宝app持的启动选项
该引擎不支持这些MATLAB启动选项:金宝app
-H
-帮助
- ?
-n
-e
-softwareopengl
-logfile
有关MATLAB启动选项的信息,请参阅常用的启动选项。
Method Summary
Static Methods
同步启动MATLAB。 |
|
异步启动MATLAB。 |
|
Find all available shared MATLAB sessions from a local machine synchronously. |
|
从异步查找本地计算机的所有可用共享MATLAB会话。 |
|
连接到本地计算机上的共享MATLAB会话。 |
|
在异步上连接到本地计算机上的共享MATLAB会话。 |
|
Connect to the current MATLAB session when called from the MATLAB environment. |
成员变量
null_writer |
采用a writer that ignores the contents from the MATLAB command window. |
Member Functions
使用参数同步评估MATLAB函数。 |
|
通过异步评估MATLAB函数。 |
|
Evaluate a MATLAB expression as a string synchronously. |
|
将MATLAB表达式评估为异步。 |
|
同步从MATLAB基本工作区获取变量。 |
|
Get a variable from the MATLAB base workspace asynchronously. |
|
Put a variable into the MATLAB base workspace synchronously. |
|
Put a variable into the MATLAB base workspace asynchronously. |
|
同步断开当前MATLAB会话的连接。 |
|
Disconnect from the current MATLAB session asynchronously. |
|
Force the shutdown of the current MATLAB session synchronously. |
|
Force the shutdown of the current MATLAB session asynchronously. |
|
断开或终止当前MATLAB会话。 |
方法详细信息
StartMatlab
static MatlabEngine startMatlab(String[] options)
静态Matlabengine Startmatlab()
同步启动MATLAB。
|
启动选项用于启动MATLAB引擎。您可以指定多个启动选项。该引擎支持所有MATL金宝appAB启动选项,除了列出的选项不支金宝app持的启动选项。有关选项列表,请参见特定于平台的命令 |
实例MatlabEngine
|
MATLABfails to start. |
字符串[]选项= {"-noFigureWindows", "-r", "cd H:"}; MatlabEngine eng = MatlabEngine.startMatlab(options);
StartMatlabAsync
静态未来
static Future
异步启动MATLAB。Once MATLAB has started, then cancel is a no-op.
|
启动选项用于启动MATLAB引擎。您可以指定多个启动选项。该引擎支持所有MATL金宝appAB启动选项,除了列出的选项不支金宝app持的启动选项。有关选项列表,请参见特定于平台的命令 |
实例Future
未来future = matlabengine.startmatlabasync();
Findmatlab
静态字符串[] findmatlab()
同步在本地计算机上找到所有共享的MATLAB会话。
An array of the names of all shared MATLAB sessions on the local machine, or an empty vector if there are no shared MATLAB sessions available on the local machine.
|
If there is a failure during the search for MATLAB sessions. |
String[] engines = MatlabEngine.findMatlab();
FindmatlabAsync
静态未来
异步在本地机器上找到所有共享的MATLAB会话。
一个实例未来
未来未来= matlabengine.findmatlabasync();
ConnectMatlab
静态Matlabengine ConnectMatlab(字符串名称)
静态Matlabengine ConnectMatlab()
Connect to a shared session on local machine synchronously.
如果指定共享MATLAB会话的名称,但是引擎找不到带有该名称的会话,则引擎会引发异常。
如果您没有指定名称,并且没有共享MATLAB会话,则引擎启动了带有默认选项的新共享MATLAB会话。
如果您不指定名称并且有共享的MATLAB会话可用,则引擎将连接到第一个可用的会话。
To connect to the current MATLAB session when called from the MATLAB environment, usegetCurrentMatlab
instead.
|
Name of the shared MATLAB session. UseFindmatlabto get the names of shared MATLAB sessions. |
一个实例MatlabEngine
|
MATLAB无法启动或连接。 |
matlabengine Engine = matlabengine.connectMatlab();
ConnectMatlabasync
静态未来
静态未来
异步连接到本地计算机上的共享MATLAB会话。行为与ConnectMatlab
除了该机制是异步的。一旦与MATLAB建立了连接,则取消是一个无操作。
|
Name of the shared MATLAB session. |
一个实例Future
Futurefuture = MatlabEngine.connectMatlabAsync();
getCurrentMatlab
静态matlabengine getCurrentMatlab()
Connect to the current MATLAB session when called from the MATLAB environment.
要连接到MATLAB会话时,请使用引擎应用程序ConnectMatlab
。
一个实例MatlabEngine
|
来自用户线程的呼叫不支持。金宝app |
Matlabengine Engine = Matlabengine.getCurrentMatlab();
Feval
使用输入参数同步评估MATLAB函数。
|
MATLAB函数或脚本要评估的名称。 |
|
预期输出的数量。默认值为1。 If If If |
|
流用于存储MATLAB函数的标准输出。如果未指定作者,则输出将写入命令窗口或终端。采用 |
|
流用于存储MATLAB函数的标准误差。如果未指定作者,则输出将写入命令窗口或终端。采用 |
|
参数传递到MATLAB函数。 |
Result of executing the MATLAB function
|
MATLAB功能的评估被取消。 |
|
MATLAB功能的评估中断。 |
|
MATLAB会话不可用。 |
|
该功能中有MATLAB运行时错误。 |
|
有一种不支持的数据类型。金宝app |
|
There is a syntax error in the MATLAB function. |
double结果= Engine.Feval(“ SQRT”,4);
FevalAsync
Evaluate MATLAB functions with input arguments asynchronously.
|
MATLAB函数或脚本要评估的名称。 |
|
预期输出的数量。默认为 If If If |
|
流用于存储MATLAB函数的标准输出。如果未指定作者,则输出将写入命令窗口或终端。采用 |
|
流用于存储MATLAB函数的标准误差。如果未指定作者,则输出将写入命令窗口或终端。采用 |
|
参数传递到MATLAB函数。 |
一个实例未来
|
MATLAB会话不可用。 |
Futurefuture = Engine.fevalasync(“ SQRT”,4);
eval
void eval(String command, Writer output, Writer error)
void eval(String command)
将MATLAB语句同步评估。
|
MATLAB语句评估。 |
|
流用于存储MATLAB语句的标准输出。如果未指定作者,则输出将写入命令窗口或终端。采用 |
|
Stream used to store the standard error from the MATLAB statement. If you do not specify a writer, the output is written to the command window or terminal. Use |
|
MATLAB功能的评估被取消。 |
|
MATLAB功能的评估中断。 |
|
MATLAB会话不可用。 |
|
There is an error in the MATLAB statement during runtime. |
|
MATLAB语句中存在语法错误。 |
Engine.eval(“结果= SQRT(4)”);
estarync
Future
Future
Evaluate a MATLAB statement as a string asynchronously.
|
MATLAB语句评估。 |
|
流用于存储MATLAB语句的标准输出。如果未指定作者,则输出将写入命令窗口或终端。采用 |
|
Stream used to store the standard error from the MATLAB statement. If you do not specify a writer, the output is written to the command window or terminal. Use |
一个实例未来
|
MATLAB会话不可用。 |
Futurefuture = Engine.evalasync(“ sqrt(4)”);
可差异
从MATLAB基本工作区获取变量。
|
MATLAB基本工作区中变量的名称。 |
Variable passed from the MATLAB base workspace
|
该功能的评估被取消。 |
|
Evaluation of this function is interrupted. |
|
MATLAB会话不可用。 |
double myvar = Engine.getVariable(“ myvar”);
getVariableasync
Get a variable from the MATLAB base workspace asynchronously.
|
Name of a variable in MATLAB base workspace. |
一个实例未来
|
MATLAB会话不可用。 |
Futurefuture = engine.getVariableAsync("myVar");
putVariable
void putvariable(字符串varname,t vardata)
将变量放入MATLAB基本工作区。
|
在MATLAB基本工作区中创建的变量的名称。 |
|
在MATLAB基本工作区中创建变量的值。 |
|
该功能的评估被取消。 |
|
Evaluation of this function is interrupted. |
|
MATLAB会话不可用。 |
Engine.putVariable(“ MyVar”,100);
putvariableasync
未来
Put a variable into the MATLAB base workspace asynchronously.
|
在MATLAB基本工作区中创建的变量的名称。 |
|
在MATLAB基本工作区中创建变量的值。 |
一个实例未来
|
MATLAB会话不可用。 |
Futurefuture = Engine.putvariableasync(“ myvar”,100);
断开
void disconnect()
与当前的MATLAB会话断开连接。
|
当前的MATLAB会话无法断开连接。 |
Engine.disconnect();
脱节
未来
与当前的MATLAB会话断开连接。
Futurefuture = Engine.disconnectasync();
辞职
void quit()
Force the shutdown of the current MATLAB session.
|
The current MATLAB session cannot be shut down. |
egine.quit();
辞职Async
未来
强制当前MATLAB会话的关闭,而无需等待终止。
一个实例未来
Futurefuture = Engine.quitasync();
close
void Close()
MatlabEngine
提供关闭()
method to implement thejava.lang.autoclosable
接口MatlabEngine
objects. This关闭()
method enables you to use a尝试
- 借助Resources语句自动断开或终止语句末尾的MATLAB会话。
TheMatlabEngine
关闭()
方法根据上下文断开或终止当前MATLAB会话。
如果Java进程以默认的非共享会话开始MATLAB会话,则
关闭()
terminates MATLAB.If the MATLAB session is a shared session,
关闭()
断开MATLAB与此Java过程的连接。MATLAB在没有其他连接时终止。
要强制关闭或断开当前MATLAB会话的连接,请明确致电matlabengine.quit()
,matlabengine.disconnect()
,或他们的异步对应物。
engine.close();