How do I call a COM object created using MATLAB Builder for .NET 2.0 (R2006a) in a C++ file?
1 回表示 (過去 30 日間)
古いコメントを表示
I have created a COM object using MATLAB Builder for .NET 2.0 (R2006a). I would like an example on calling this from within a C++ file.
採用された回答
MathWorks Support Team
2010 年 1 月 28 日
An example on doing this is attached here. Note that this example would also work if the COM object was built with MATLAB Builder for COM.
The attached ZIP-file contains 2 MATLAB files (addmatrix.m and transposematrix.m) and a CPP-file (test.cpp). Use the files as detailed below:
1. Execute
mbuild -setup
at the MATLAB command prompt and select a supported C++ compiler such as Microsoft Visual Studio 8.0. Note that the LCC compiler cannot be used to build the component as the version of LCC compiler that ships with MATLAB is a C compiler.
2. Launch DOTNETTOOL by typing
dotnettool
at the MATLAB command prompt.
3. Create a new project by selecting "File -> New Project" menu item and enter the component name as 'myMatrix'. Accept the default class name and project settings.
4. Once you are returned to the MATLAB Builder window, highlight the component, click the "Add File" button and add addmatrix.m and transposematrix.m
5. Select "Build -> COM object" from the menu to build the COM object.
6. Open the CPP-file and observe that addmatrix and transposematrix are invoked as methods of the COM object.
0 件のコメント
その他の回答 (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!