Call matlab script in IDL

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 DThe 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 ximagThe 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.

相关文章
相关标签/搜索