programatically exporting the code behind an .mlapp to an m file.

97 ビュー (過去 30 日間)
Christopher Ward
Christopher Ward 2020 年 12 月 7 日
コメント済み: Xingwang Yong 2024 年 1 月 9 日
Appdesigner offers a way to export the underlying code out of the binary .mlapp to a .m file with a save as type dialog. This being the only way around storing in git for source control purposes. I want to be able to keep all these export for all the apps housed in a project in a seperate folder, to prevent clutter of the project. While I can maually hit the "export" menuitem , I then have to change the path and repeat indiviually.
Does anyone know if the method behind the menu item is exposed to the matalb command line so that a script could be used to semi automate?
chris

採用された回答

Mario Malic
Mario Malic 2020 年 12 月 7 日
Hey Chris,
If you set up your application as a project, and use MATLAB's Source Control to share your project to Git, you are able to inspect the differences within MATLAB, which probably is the correct way to do what you want to do.
Optional info below:
If you unzip the file, under 'matlab' folder, there's a file called 'document.xml' which contains the script you see in App Designer, however, you can only use it to see the changes, but you cannot reuse the file, as it is not yet known to us how to change data inside and have a working application.
  2 件のコメント
Steven Lord
Steven Lord 2020 年 12 月 7 日
This documentation page includes instructions on how to configure your SCM to use tools provided by MathWorks to diff and merge our binary file formats.
Christopher Ward
Christopher Ward 2020 年 12 月 7 日
Ahh I've just seen that as of R2020b appdesigner mlapps can be differenced and merged within Matlab without the need to export. This is great, problem resolved.

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

その他の回答 (1 件)

Duijnhouwer
Duijnhouwer 2023 年 3 月 21 日
You could add this to your MLAPP's startupFnc
writelines(evalc('type(mfilename(''fullpath'')+".mlapp")'),mfilename('fullpath')+".txt");
Each time you run the app, this will export the code as text for easy tracking with GIT.

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by