How can I find out to which VARIANT type a MATLAB variable is converted?

조회 수: 1 (최근 30일)
I have a COM object that expects a variable of type Variant(Optional). I would like to know how MATLAB data types are mapped to COM VARIANT types so that I can pass the correct data.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2010년 3월 15일
Most MATLAB data types are mapped to a certain VARIANT type. As of R2010a, there are some unsupported MATLAB types, but limitations are subject to change in newer releases.
The attached component can be used to find out how MATLAB data types are mapped to VARIANT types and to test for different behavior in different releases. Installation and requirement information is included in the ZIP file. The following example shows how to use the component:
>> varTester = actxserver('VariantTester.Tester')
varTester =
COM.VariantTester_Tester
>> varTester.invoke
TestVariant = string TestVariant(handle, Variant(Optional))
>> varTester.TestVariant()
ans =
VT_ERROR (SCODE)
>> varTester.TestVariant('Hello world')
ans =
VT_BSTR (BSTR)
>> varTester.TestVariant(12345)
ans =
VT_R8 (DOUBLE)
>> varTester.TestVariant([])
ans =
VT_ERROR (SCODE)
>> varTester.TestVariant([123 456])
ans =
VT_ARRAY | VT_R8 (DOUBLE)
>> varTester.TestVariant({'123' '456'})
ans =
VT_ARRAY | VT_VARIANT
>> varTester.TestVariant(int8(123))
ans =
VT_I1 (CHAR)
>> varTester.TestVariant(int16(123))
ans =
VT_I2 (SHORT)
>> varTester.TestVariant(int32(123))
ans =
VT_I4 (LONG)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Excel Add-Ins에 대해 자세히 알아보기

제품


릴리스

R2010a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by