フィルターのクリア

Matlab doesn't release the C code execution until completion of the script

2 ビュー (過去 30 日間)
Alex Sidorov
Alex Sidorov 2022 年 4 月 19 日
編集済み: Bruno Luong 2022 年 4 月 19 日
The C app send command to the matlab for script M file launching and the matlab doesn't release the C code execution, return from call function, until the m script completion. How to resolve this issue. How C code can run m script and continue to execute other operators and functions?
ex:
const char ptrMatlabCommandStart[] = "run(\"example.m\")";
ep = engOpen(NULL); // open C2M engine
engEvalString(ep, ptrMatlabCommand) // launch example.m script
a = b; // can't be performed until end of the example.m script
Also very interaesting following implementation of C code functionality:
  1. pa = mxCreateDoubleScalar(value); // initialize in matlab worklspace by C code
  2. mxSetDoubles(pa, value); // set value in matlab worklspace by C code
  3. engEvalString(ep, ptrMatlabCommand); // launch matlab script that use value
for ()
{
4. mxSetDoubles(pa, value); // update value in matlab worklspace by C code and impact to matlab script results
// matlab script computes according to the new value - parameter
// matlab also can change value according to launched script
}
5. value = *mxGetDoubles(pa); // read updated value in C app

採用された回答

Bruno Luong
Bruno Luong 2022 年 4 月 19 日
編集済み: Bruno Luong 2022 年 4 月 19 日
MATLAB is essential sequential/blocking behavior. Whereas you call a function from C or Matlab yo have to wait until completion.
However if you have recent MATLAB you can run a function (restricted capability) in background and get the hand back instantanously using parfval

その他の回答 (1 件)

Alex Sidorov
Alex Sidorov 2022 年 4 月 19 日
Great, thanks :)

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by