Is it possible to keep Matlab objects as mxArray type in C++ application ?

1 view (last 30 days)
Hi,
i am planning on writing an application in C++ and i want to use certain Matlab functions as a .dll that can be compiled with the mcc. Further more i want to make use of objects implemented in Matlab, that i want to pass from one Matlab dll function to another. But therefore i need to store it in an mxArray, or something that the calling application can handle. Is that possible and how would it be done ? So more general, how can Matlab objects be used in C++ ? Sorry if the question is not very detailed, but i am at a very early stage, and just want to check out the possibilities. Any hint will be greatly appreciated. Thanks in advance, ...

Accepted Answer

James Tursa
James Tursa on 18 Feb 2016
Edited: James Tursa on 18 Feb 2016
How do you plan on calling the MATLAB functions? With the Engine API interface? If so, then as long as you build the application properly with the API library links you should be able to create & store mxArray objects for your eventual MATLAB function calls via the Engine. E.g., see this link:
Note, however, that using a MATLAB Engine will cause deep copies of the mxArray variables whenever you pass arguments to the Engine and retrieve the results.
  1 Comment
Ulrich
Ulrich on 22 Feb 2016
Hi, and thanks for the answer. Just to clarify: It is possible to store more complex MATLAB objects (with methods and stuff) in a simple mxArray ?

Sign in to comment.

More Answers (0)

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!