# com.matlab 库模块帮助文档

[aardio + MATLAB 编程入门指南](https://www.aardio.com/zh-cn/docs/library-guide/std/com/matlab.html)

## com 成员列表 <a id="com" href="#com">&#x23;</a>

### com.matlab <a id="com.matlab" href="#com.matlab">&#x23;</a>
MATLAB 应用程序对象。

### com.matlab(hidden,progId) <a id="com.matlab" href="#com.matlab">&#x23;</a>
创建或获取已打开的 MATLAB 应用程序对象。  
@hidden 指定是否隐藏创建的窗口，如果连接到已打开的 MATLAB 应用则此选项无效。  
可选用 @progId 参数中指定 ProgID。  

[返回对象:comMatLabObject](#comMatLabObject)

## comMatLabObject 成员列表 <a id="comMatLabObject" href="#comMatLabObject">&#x23;</a>

### comMatLabObject.* <a id="comMatLabObject.any" href="#comMatLabObject.any">&#x23;</a>
指定 MATLAB 函数名，调用 MATLAB 函数对象。  
第 1 个参数指定返回值数量（无参数，或首个参数不是数值可省略，默认为 1）。

### comMatLabObject.addpath() <a id="comMatLabObject.addpath" href="#comMatLabObject.addpath">&#x23;</a>
添加搜索目录。  
https://ww2.mathworks.cn/support/search.html?q=addpath

### comMatLabObject.base <a id="comMatLabObject.base" href="#comMatLabObject.base">&#x23;</a>
MATLAB 基础工作区。  

[返回对象:comMatLabWsObject](#comMatLabWsObject)

### comMatLabObject.cd() <a id="comMatLabObject.cd" href="#comMatLabObject.cd">&#x23;</a>
修改当前目录为参数 @1 指定的目录。  
不指定参数默认切换到应用程序目录 "/" 。  
返回旧的工作目录。

### comMatLabObject.code <a id="comMatLabObject.code" href="#comMatLabObject.code">&#x23;</a>

```aardio
comMatLabObject.code = /******  
/*执行 MATLAB 命令，可用模板语法在 <? ?> 标记内嵌入 aardio 代码或对象。*/  
******/
```

### comMatLabObject.eval() <a id="comMatLabObject.eval" href="#comMatLabObject.eval">&#x23;</a>
解析字符串参数 @1 指定的 MATLAB 表达式，返回解析结果。  
也可以在下标操作符中用字符串输入表达式，可自动调用 eval 函数返回结果。

### comMatLabObject.evalin() <a id="comMatLabObject.evalin" href="#comMatLabObject.evalin">&#x23;</a>
在参数 @1 指定的工作区计算表达式。

### comMatLabObject.exec() <a id="comMatLabObject.exec" href="#comMatLabObject.exec">&#x23;</a>
执行字符串命名，并返回字符串值。

### comMatLabObject.figure('Name','新标题','NumberTitle','off') <a id="comMatLabObject.figure" href="#comMatLabObject.figure">&#x23;</a>
修改窗口标题

### comMatLabObject.figure('Visible', 'on') <a id="comMatLabObject.figure" href="#comMatLabObject.figure">&#x23;</a>
显示绘图窗口，参数 @2 设为 "off" 隐藏绘图窗口。

### comMatLabObject.getData() <a id="comMatLabObject.getData" href="#comMatLabObject.getData">&#x23;</a>
自参数 @2 指定名字的工作区获取参数 @1 指定变量名的值。  
返回 2 个值，分别为 矩阵的实部和虚部。

### comMatLabObject.getMatrix() <a id="comMatLabObject.getMatrix" href="#comMatLabObject.getMatrix">&#x23;</a>
自参数 @2 指定名字的工作区获取参数 @1 指定变量名的矩阵。  
返回 2 个值，分别为 矩阵的实部和虚部。

### comMatLabObject.getString() <a id="comMatLabObject.getString" href="#comMatLabObject.getString">&#x23;</a>
自参数 @2 指定名字的工作区获取参数 @1 指定变量名的字符串。  
返回 2 个值，分别为 矩阵的实部和虚部。

### comMatLabObject.global <a id="comMatLabObject.global" href="#comMatLabObject.global">&#x23;</a>
MATLAB 全局工作区。  

[返回对象:comMatLabWsObject](#comMatLabWsObject)

### comMatLabObject.maximize() <a id="comMatLabObject.maximize" href="#comMatLabObject.maximize">&#x23;</a>
最大化 MATLAB 命令行窗口。

### comMatLabObject.minimize() <a id="comMatLabObject.minimize" href="#comMatLabObject.minimize">&#x23;</a>
最小化 MATLAB 命令行窗口。

### comMatLabObject.putData <a id="comMatLabObject.putData" href="#comMatLabObject.putData">&#x23;</a>
将变量值存储到工作区。  
也可以直接读写 base,global 属性的成员值。

### comMatLabObject.putData(varname,workSpace,data) <a id="comMatLabObject.putData" href="#comMatLabObject.putData">&#x23;</a>
将 @data 指定的变量值存储到工作区，并将其指定给变量 varname 。  
要注意直接读写 base,global 工作区变量时默认为 double 类型。  
而用 putData 函数写入整数时，要用 com.double 转换为 double 型。  
但遵守 COM 接口默认规则 ，小数与数组默认为 double 类型。

### comMatLabObject.putMatrix <a id="comMatLabObject.putMatrix" href="#comMatLabObject.putMatrix">&#x23;</a>
将矩阵存储到工作区

### comMatLabObject.putMatrix(varname,workSpace,xreal,ximag) <a id="comMatLabObject.putMatrix" href="#comMatLabObject.putMatrix">&#x23;</a>
将矩阵存储到工作区，并将其指定给变量 varname。  
分别将 xreal 和 ximag 用于矩阵的实部和虚部。  
矩阵不能是标量或空数组，也不能大于两维。

### comMatLabObject.putString <a id="comMatLabObject.putString" href="#comMatLabObject.putString">&#x23;</a>
将字符串存储到工作区。  
也可以直接读写 base,global 属性的成员值。

### comMatLabObject.putString(varname,workSpace,xreal,ximag) <a id="comMatLabObject.putString" href="#comMatLabObject.putString">&#x23;</a>
将字符串存储到工作区，并将其指定给变量 varname。  
分别将 xreal 和 ximag 用于矩阵的实部和虚部。  
矩阵不能是标量或空数组，也不能大于两维。

### comMatLabObject.pwd() <a id="comMatLabObject.pwd" href="#comMatLabObject.pwd">&#x23;</a>
返回当前工作目录

### comMatLabObject.quit() <a id="comMatLabObject.quit" href="#comMatLabObject.quit">&#x23;</a>
关闭 MATLAB 应用程序。

### comMatLabObject.visible <a id="comMatLabObject.visible" href="#comMatLabObject.visible">&#x23;</a>
是否显示 MATLAB 命令行窗口。

## comMatLabWsObject 成员列表 <a id="comMatLabWsObject" href="#comMatLabWsObject">&#x23;</a>

### comMatLabWsObject.* <a id="comMatLabWsObject.any" href="#comMatLabWsObject.any">&#x23;</a>
指定 MATLAB 基础工作区变量名，读写变量值。

### comMatLabWsObject.assign(tab) <a id="comMatLabWsObject.assign" href="#comMatLabWsObject.assign">&#x23;</a>

```aardio
comMatLabWsObject.assign({
	/*在参数表中定义多个名值对。  
这些名字和值将作为变量名与变量值写入工作区。*/
})
```

### comMatLabWsObject.eval() <a id="comMatLabWsObject.eval" href="#comMatLabWsObject.eval">&#x23;</a>
在工作区解析字符串参数 @1 指定的 MATLAB 表达式，返回解析结果。

### comMatLabWsObject.getData() <a id="comMatLabWsObject.getData" href="#comMatLabWsObject.getData">&#x23;</a>
自参数 @2 指定名字的工作区获取参数 @1 指定变量名的值。  
返回 2 个值，分别为 矩阵的实部和虚部。

### comMatLabWsObject.getMatrix() <a id="comMatLabWsObject.getMatrix" href="#comMatLabWsObject.getMatrix">&#x23;</a>
自工作区获取参数 @1 指定变量名的矩阵。  
返回 2 个值，分别为 矩阵的实部和虚部。

### comMatLabWsObject.putData <a id="comMatLabWsObject.putData" href="#comMatLabWsObject.putData">&#x23;</a>
将变量值存储到工作区。  
也可以直接读写 base,global 属性的成员值。

### comMatLabWsObject.putData(varname,data) <a id="comMatLabWsObject.putData" href="#comMatLabWsObject.putData">&#x23;</a>
将 @data 指定的变量值存储到工作区，并将其指定给变量 varname 。  
要注意直接读写 base,global 工作区变量时默认为 double 类型。  
而用 putData 函数写入整数时，要用 com.double 转换为 double 型。  
但遵守 COM 接口默认规则 ，小数与数组默认为 double 类型。

### comMatLabWsObject.putMatrix <a id="comMatLabWsObject.putMatrix" href="#comMatLabWsObject.putMatrix">&#x23;</a>
将矩阵存储到工作区

### comMatLabWsObject.putMatrix(varname,xreal,ximag) <a id="comMatLabWsObject.putMatrix" href="#comMatLabWsObject.putMatrix">&#x23;</a>
将矩阵存储到工作区，并将其指定给变量 varname。  
分别将 xreal 和 ximag 用于矩阵的实部和虚部。  
矩阵不能是标量或空数组，也不能大于两维。
