MATLAB standalone executable calling other MATLAB scripts

1 回表示 (過去 30 日間)
NHS
NHS 2015 年 7 月 8 日
コメント済み: Nathan Kovarik 2022 年 7 月 18 日
As part of a large piece of software for data analysis in my lab, we have designed a GUI. We have several analysis functions that generate various plots, and the visualization GUI not only provides a tool for visualizing these plots, but also takes care of some automated analysis.
We want to know if it's possible to make the GUI a standalone application, but have it call these analysis functions in such a way that we don't have to include the analysis functions in the project when building it. The reason is that we don't want to have to rebuild the entire application every time we make slight modifications to our analysis scripts.

採用された回答

Walter Roberson
Walter Roberson 2015 年 7 月 9 日
Option 1: MATLAB Production Server. Requires a server to execute the MATLAB on.
Option 2: MATLAB Automation Server (COM). MS Windows. Allows programs to control a MATLAB session. The idea here would be that the executable would provide the interface and most functions but would call upon the COM Server to do a bit of the work
Option 3: Design a mini-language that is not a general purpose language but allows some choice in what is to be done, and have the executable read the scripts as data and act on them. You have to be careful not to make the language powerful enough to violate the Mathworks Terms and Conditions.

その他の回答 (2 件)

Alex
Alex 2015 年 7 月 8 日
What you are asking is not possible. Every time you compile your GUI using deploytool, you need to provide all the dependecies (functions) in order for it compile correctly.

Nathan Kovarik
Nathan Kovarik 2021 年 8 月 3 日
I know this is super late, but I found a nice work-around for this to share. I was able to compile it into a standalone executable and it worked.
  • Copy the script into a .txt file
  • Load the .txt file with: scriptCode = fileread ("...txt");
  • Evaluate the code with: eval(scriptCode);
  2 件のコメント
ss
ss 2022 年 6 月 23 日
How did your function definitions got supported for that? When I run the eval,it just asks me to create functions in code file.
Nathan Kovarik
Nathan Kovarik 2022 年 7 月 18 日
Correct, I wasn't able to get function declared in the text to work. However, you can pass any code that doesn't include any function defitions (like a script) and execute that.
For my application, I wanted to make sure the code that could be entered into the app though this method coudn't interfere with the main program variables, so evaluated the code inside a function so that all the variables are within their own scope.
function logFileData = executeImportCode(app, importCode)
eval(importCode); % Evalute the text passed to import this file
end

サインインしてコメントする。

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by