Variable type equivalent to Variant(Optional) when using COM objects in MATLAB
1 次查看(过去 30 天)
显示 更早的评论
I am using COM objects instantiated through activexserver.
One of the methods I am trying to use has the following input argument types specification (I got it using "methodsview" function)
ReadFile = void ReadFile(handle, ustring, Variant(Optional))
The COM object in fact has an optional in the second argument, with default value NULL ([in, defaultvalue(NULL)] )
What equivalent MATLAB type can I use for the Variant(Optional) type? I have tried no providing a second argument, using empty ([]), 0.
Thanks in advance!
0 个评论
回答(1 个)
Spruha
2025-6-16
Hi Isaac,
I see you are working with a COM object and looking for a way to pass an optional second argument with a default value of NULL. In MATLAB, you can use the ‘variant([])’ function for this purpose. By passing an empty array ([]) of type double, MATLAB creates a VARIANT of type VT_EMPTY, which is commonly used to represent "no value" or NULL in COM interfaces.
Please refer to this documentation on handling COM data in MATLAB: https://www.mathworks.com/help/matlab/matlab_external/handling-com-data-in-matlab-software.html#bq4sbxq-1
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Use COM Objects in MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!