Adding a class-related function to appdesigner app

조회 수: 38 (최근 30일)
Matt J
Matt J 2026년 1월 1일
댓글: dpb 2026년 1월 7일 15:46
Is there a way, in appdesigner, to create a class-related function, i.e., a function that is local to the app's classdef file, but which is not a class method?

채택된 답변

dpb
dpb 2026년 1월 1일
편집: dpb 2026년 1월 1일
Not that I am aware of or can see an undocumented way -- the closest it allows are private methods that can serve the same purpose albeit that they have the global app struct as a mandatory argument besides any others desired. I don't see any way you can place code past the protected end of the classdef block and since the mlapp files aren't text(*), you can't try to use subterfuge and edit the file in an external editor.
If it's relatively small and tidy, I genrally just go that route; if it is really complex to do a lot of the heavy lifting I usually go ahead and write it as an external m-file and put up with that it is visible outside the app that way. Frequently I find this has some advantages in that can debug outside the app or even make separate command line tools without the need of the GUI. When doing that, the internal properties are dereferenced and passed as individual arguments or part of a struct and don't pass the app struct itself.
Agree, it would be a welcome facility and worthy of an enhancement request.
(*) Interestingly, the MATLAB type command knows enough to present them as if were text which can fool one if looking only with MATLAB tools.
  댓글 수: 7
Matt J
Matt J 2026년 1월 7일 15:06
I did submit an enhancement request. They were receptive but, as usual, they wouldn't commit up front to its implementation.
dpb
dpb 2026년 1월 7일 15:46
Roger. Thanks...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by