Is it possible to pass pointers to MATLAB structures through a COM interface?
Mostrar comentarios más antiguos
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 comentarios
Isaac Sherman
el 3 de Feb. de 2016
James Tursa
el 3 de Feb. de 2016
I am not familiar with this interface. What exactly are you allowed to pass back & forth?
Isaac Sherman
el 3 de Feb. de 2016
James Tursa
el 3 de Feb. de 2016
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
el 3 de Feb. de 2016
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
el 3 de Feb. de 2016
Editada: Isaac Sherman
el 3 de Feb. de 2016
Respuesta aceptada
Más respuestas (1)
James Tursa
el 3 de Feb. de 2016
1 voto
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 comentarios
Isaac Sherman
el 3 de Feb. de 2016
Walter Roberson
el 3 de Feb. de 2016
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.
Categorías
Más información sobre Write COM Applications to Work with MATLAB en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!