App Designer. Should I use app functions or external fuctions?

9 ビュー (過去 30 日間)
Javier Mateo
Javier Mateo 2021 年 8 月 31 日
編集済み: Adam Danz 2021 年 9 月 1 日
I created a "program" based in scripts and functions and I have merged it into an app from App designer to make it more user friendly. However, I noticed that the "same" operations are now much slower and crashing more often than when I was not using the App designer, so I wonder if the app somehow makes it less efficient.
I am using "app" functions written in the app code. I wonder If I should externalize all the functions and create isolated function files so I can call them from the app code. One of the reasons I prefer the internal app functions is because I play with some properties shared between the functions. But I guess I can pass the properties/variables trough the functions arguments.

採用された回答

Adam Danz
Adam Danz 2021 年 8 月 31 日
編集済み: Adam Danz 2021 年 9 月 1 日
> I noticed that the "same" operations are now much slower and crashing more often than when I was not using the App designer, so I wonder if the app somehow makes it less efficient.
App have a slower startup time than using m-files directly. Rendering in UIFigures is also slower than rendering in regular figures. Other than that, running code from an app isn't noticeably slower than outside of an app in my exerpience. If the code works outside of app designer, it shouldn't crash within app designer. So there may be some errors in your implementation or severe suboptimalities, or perhaps you've found a bug. Sharing error messages, describing user interactions that cause a crash, or providing the files needed to reproduce the crash would be helpful, along with knowing your Matlab release.
> I am using "app" functions written in the app code. I wonder If I should externalize all the functions and create isolated function files so I can call them from the app code.
I answered a similar question yesterday. There are limited circumstances that I would recommend using external m-file functions.
  1. if the function is used by other functions, obviously it should remain external in most cases.
  2. If the function is very long and you'd like to keep the app code short and sweet. In your case, it sounds like the function should be internal to the app so you can share properties more efficiently as you've mentioned.

その他の回答 (0 件)

カテゴリ

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