Can MATLAB use a MEX Function that run continuously?
古いコメントを表示
I have a socketing program writtne in C++ which runs continously and I'm trying to use MATLAB to plot the data. I looked into MEX functions but all the examples are of functions that execute and return a single value. Is there a way to continuously feed data from C++ into MATLAB and produce live graphs?
3 件のコメント
Walter Roberson
2018 年 11 月 13 日
perhaps invert the flow?
https://www.mathworks.com/help/matlab/calling-matlab-engine-from-c-programs-1.html
NaiveMeasurement
2018 年 11 月 13 日
Walter Roberson
2018 年 11 月 13 日
MATLAB uses a single main execution thread unless you use the Parallel Computing Toolbox. When you call into .mex then nothing in the main MATLAB engine can get done, including not processing any graphics that has not been handed over to the graphics thread already. Even timers cannot execute.
So if you infinite loop in mex doing data collection, then you cannot process the data on the MATLAB side.
It is valid to collect multiple values before returning, and there is always a trade off between waiting collecting values efficiently and returning for more processing, against function call overhead every time you go back for more data: the less data you collect the faster you can react to each datum but the more overhead in the collecting.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Call C++ from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!