MATLAB Answers

Package and class folders are not supported in app designer?

36 ビュー (過去 30 日間)
abblah abblah
abblah abblah 2020 年 3 月 15 日
編集済み: J. Alex Lee 2020 年 4 月 19 日
Should the *.mlapp files be in the MATLAB root folder or path? why app file can not be in the package and class folders such as +ui and @myapp folder?
In other words, how can we define multiple methods in separate files according to @myapp class using app designer?
writing all methods in the app designer editor is not rational in developing big applications.
Note that with exporting the mfile version from the app designer, package and class folders are supported but if any changes in the user interface be required,
the app designer drag and drop environment can not be used and adding new component should be done manually by code :((

  2 件のコメント

Mohammad Sami
Mohammad Sami 2020 年 3 月 16 日
The best work around I have found is to use app designer purely for UI. For callbacks you can just call external functions. These can then be managed as code files outside of app designer.
J. Alex Lee
J. Alex Lee 2020 年 3 月 16 日
+1 Mohammad's comment...but only problem is if you want your callbacks to actually be app methods, in which case you could make an app method which is a wrapper to your external function. But you still can't really control access. It's probably a moot point if your intention is to deploy as stand-alone.
Another down side of exporting as .m file is if you want to publish to a web app, I don't think it will be possible anymore.



Arthur Roué
Arthur Roué 2020 年 3 月 16 日
編集済み: Arthur Roué 2020 年 3 月 16 日
You can create a class folder @MyApp with the file MyApp.mlapp as constructor. Then you can create methods in separate files.

  5 件のコメント

表示 2 件の古いコメント
J. Alex Lee
J. Alex Lee 2020 年 3 月 17 日
Oh, I was trying to use the "run" button. I got it to work now too.
Regarding item 3:
You could still leave the callback undefined in the appdesigner, and manually set the callback to an externally defined method in the startupfcn.
Another oddity is that for this to work, you don't even need to declare the method within a methods block in the .mlapp, although if you do, it seems you can still use the attributes as usual.
Is this all documented somewhere? Googling didn't help me...
Arthur Roué
Arthur Roué 2020 年 3 月 17 日
By default, a method in a separate will be a public one. You can change the scope by writing the function prototype in the *.mlapp in the desired section. For instance :
methods (Static)
% A static function defined in another file
[out1, out2] = ajouterAsterisque(arg1, arg2)
You can also defined private function in a subfolder private of your folder class.
J. Alex Lee
J. Alex Lee 2020 年 4 月 19 日
If you want to compile an mlapp into a web app, you need to create the web app project from the main Matlab menu; if you try to "share web" from within app designer, it will fail, I think because of the @ symbol in the class folde rname; it gives you an error about project name.


その他の回答 (0 件)


Community Treasure Hunt

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

Start Hunting!

Translated by