Matlab/Simulink Objects in C++ application
1 view (last 30 days)
Show older comments
Hi I'm developing a system where the model will get executed as RTWT kernel and user interaction is through a GUI which is developed using VC. I Could start the model execution through the GUI as specified in the tutorial. But I couldn't get any information on how to send the user inputs to the model and get the outputs from the model to the GUI. I tried with UDP sockets but It buffers the data which results a delay between GUI and model. Is there any other option to interact with the model from a C++ application?. I had done the same thing with GUI developed in MATLAB with event handler call backs. Similar thing can we implement here?
Expecting Reply
Vijeesh T NAL, Bangalore, India
0 Comments
Answers (3)
Kaustubha Govind
on 21 Feb 2012
If you're using a PC-based GUI, you are essentially losing the "real-time" processing that the RTWT kernel provides - is there a reason that you have to use RTWT? Typically RTWT models are interfaced directly with hardware, so most of the driver blocks are associated with supported hardware.
Why not use a regular Embedded Coder (formerly, Real-Time Workshop Embedded Coder) generated shared library (DLL) and call into that from your GUI?
PS: I have no expertise in the RTWT area, but I know that attempting to interface custom drivers with RTWT is not easy, so I won't go so far as to suggest that you implement your own interface.
0 Comments
Vijeesh
on 21 Feb 2012
1 Comment
Kaustubha Govind
on 22 Feb 2012
Yes, I think you should be able to use the MATLAB Engine API so that MATLAB is started as a COM server - you can then write MATLAB functions that use the Simulink command-line API to control your model (http://www.mathworks.com/support/tech-notes/1900/1903.html). You simply need to execute the appropriate MATLAB function using engEvalString when an event occurs on your GUI.
Vijeesh
on 22 Feb 2012
1 Comment
Kaustubha Govind
on 22 Feb 2012
As far as I know, the output of statements like disp are displayed in the MATLAB COM Server. The server can be made visible by setting the 'Visible' property of the COM object to true. The COM object itself is not exposed through the Engine API, so might want to use the COM API directly to start and interface with the MATLAB COM Server.
See Also
Categories
Find more on Deploy to C++ Applications Using MATLAB Data API (C++11) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!