How can I send and receive data to MATLAB from a C++ application?
4 ビュー (過去 30 日間)
古いコメントを表示
I need to send data and receive data from a C++ application from MATLAB (and later use that code in Simulink). The C++ program use a API to control a drone to handle the WiFi connection. All the common are done by the API, seen command, read sensor etc. But it MUST use a multi-threaded architecture to work.
I think .mex file won't work for that type of application, if I understand it only call subroutine, but I might be wrong.
I have also looked at the Engine API that allow a C++ program to call MATLAB code. But I need the MATLAB code to control the iteration. I am not sure if it can work well with Simulink or if it will just be really ugly.
At last I have think of using TCP/IP to communicate with the C++ application.
Anyone have suggestion to how to implement that?
0 件のコメント
回答 (2 件)
Seth Popinchalk
2011 年 1 月 22 日
To start, write a MATLAB MEX function that you can call to send and receive commands from MATLAB to the C++ program through whatever API might be available. Once this is working, you should be able to incorporate similar code into an S-function. The S-function can then run as part of a Simulink model to control the drone through the C++ program.
1 件のコメント
Seth Popinchalk
2011 年 1 月 22 日
This is a high-level answer. If you need further help with implementation, try asking smaller questions about the details.
Walter Roberson
2011 年 2 月 7 日
Matlab has a single control thread; even if you were to use the Parallel Processing Toolkit, it is doubtful that it would be considered a "multi-threaded architecture" for your purposes.
In order to use TCP/IP with Matlab, you need the Instrument Control Toolbox, or else you need to use the Matlab File Exchange contribution "tcpudpip" (which uses the Netcat libraries.) When I look around a bit, I do not find confirmation that Netcat is multi-threaded; the source would have to be examined.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!