MATLAB Answers

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

조회 수: 4(최근 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개)

Community Treasure Hunt

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

Start Hunting!

Translated by