Call matlab script in IDL

这篇博客介绍了如何在IDL环境中通过COM自动化服务器接口获取并处理MATLAB工作空间中的数据,强调了在数据传输时要确保是1D数据,并且提供了解析2D矩阵的方法。对于VBScript客户端,推荐使用特定的函数进行数值数据的传递。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

pro test
   oMatlab = obj_new('IDLcomIDispatch$ProgID$Matlab_application_7.13')    ; or 9.5
   ;use '..._6' instead if you use Matlab 6.x
   ;oMatlab -> setProperty, visible=0
   a = 4.8
   oMatlab -> PutWorkspaceData, 'b', 'base', a
   oMatlab -> Execute, 'c = fix(b);'
   oMatlab -> GetWorkspaceData, 'c', 'base', d
   help, a, b, c, d
   obj_destroy, oMatlab
end


Be sure to supply 1D data when transferring! Use reform or reshape before and after the transfer.

MATLAB API for COM Automation Server

GetWorkspaceData

Data from Automation server workspace

Synopsis

IDL Method Signature

HRESULT GetWorkspaceData([in] BSTR varname, [in] BSTR workspace, 

    [out] VARIANT* pdata)

Microsoft Visual Basic Client

GetWorkspaceData(varname As String, workspace As String) As Object

MATLAB Client

D = GetWorkspaceData(h,'varname','workspace')

Description

D = GetWorkspaceData(h,'varname','workspace') gets data stored in variable varname from the specified workspace of the server attached to handle h and returns it in output argument D. The values for workspace are base or global.

Use GetWorkspaceData instead of GetFullMatrix and GetCharArray to get numeric and character array data, respectively. Do not use GetWorkspaceData on sparse arrays, structures, or function handles.

For VBScript clients, use the GetWorkspaceData and PutWorkspaceData functions to pass numeric data to and from the MATLAB® workspace. These functions use the variant data type instead of the safearray data type used by GetFullMatrixand PutFullMatrix. VBScript does not support safearray.


GetFullMatrix

Matrix from Automation server workspace

Synopsis

IDL Method Signature

GetFullMatrix([in] BSTR varname, [in] BSTR workspace, 

    [in, out] SAFEARRAY(double) *pr, [in, out] SAFEARRAY(double) *pi)

Microsoft Visual Basic Client

GetFullMatrix(varname As String, workspace As String, 

    [out] XReal As Double, [out] XImag As Double

MATLAB Client

[xreal ximag] = GetFullMatrix(h,'varname','workspace',zreal,zimag)

Description

[xreal ximag] = GetFullMatrix(h,'varname','workspace',zreal,zimag) gets matrix stored in variable varname from the specified workspace of the server attached to handle h. The function returns the real part in xreal and the imaginary part in ximag. The values for workspace are base or global.

The zreal and zimag arguments are matrices of the same size as the real and imaginary matrices (xreal and ximag) returned from the server. The zreal and zimag matrices are commonly set to zero.

Use GetFullMatrix for 2D matrices with values of type double only. Use GetVariable or GetWorkspaceData for other types. To use higher dimensional matrices, reshape the 2D matrix after receiving it from MATLAB®.

For VBScript clients, use the GetWorkspaceData and PutWorkspaceData functions to pass numeric data to and from the MATLAB workspace. These functions use the variant data type instead of the safearray data type used by GetFullMatrix and PutFullMatrix. VBScript does not support safearray.



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值