Is it possible to pass pointers to MATLAB structures through a COM interface?
古いコメントを表示
I generate a few classifiers in MATLAB through a COM interface. I would like to pass a pointer to them, the MATLAB classifiers, back through the COM interface, so that I can use them later if necessary (say, to call Predict on data I'm streaming from somewhere) I don't need to do anything to the classifier in my code, I just want to hang onto it and use it after training and other operations have been accomplished.
So to be clear, I don't need to do anything to the pointer except hang on to it in my code, and pass it back to MATLAB to tell it which structure it should use.
Is this possible?
6 件のコメント
Isaac Sherman
2016 年 2 月 3 日
James Tursa
2016 年 2 月 3 日
I am not familiar with this interface. What exactly are you allowed to pass back & forth?
Isaac Sherman
2016 年 2 月 3 日
James Tursa
2016 年 2 月 3 日
Just to clarify, are you trying to examine the contents of these classifier structs inside the C/C++ code to determine which one is "best"? And then communicate that back to MATLAB?
Guillaume
2016 年 2 月 3 日
My understanding is that the code is written in C# and that the COM interface is automatically generated by .Net. I don't think there's any C/C++ code involved.
Regardless, I'm also confused as to which way the structure is traveling.
Isaac Sherman
2016 年 2 月 3 日
編集済み: Isaac Sherman
2016 年 2 月 3 日
採用された回答
その他の回答 (1 件)
James Tursa
2016 年 2 月 3 日
1 投票
Not sure how you have your particular COM interface set up. But, e.g. the MATLAB Engine API connection from a C/C++ program to MATLAB is through a COM interface. In this case, these are separate processes that interact through this COM interface, and as such have separate memory. So any pointer that was passed from one process would be invalid to use in the other process. I.e., if a MATLAB object was created in the Engine and a pointer to it was passed back through the COM interface to the C/C++ program, you couldn't use the pointer in your C/C++ program because the memory behind the pointer does not belong to your C/C++ process ... it belongs to the MATLAB Engine process. The pointer is invalid as far as your C/C++ program is concerned. Attempting to use it would likely crash your C/C++ program.
2 件のコメント
Isaac Sherman
2016 年 2 月 3 日
Walter Roberson
2016 年 2 月 3 日
If the MATLAB session has not been closed, pass back an index number, which you can use to index a struct or cell array of data or cell array of function handles.
カテゴリ
ヘルプ センター および File Exchange で Write COM Applications to Work with MATLAB についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!