Adding a class-related function to appdesigner app

36 visualizaciones (últimos 30 días)
Matt J
Matt J hace alrededor de 23 horas
Editada: dpb hace alrededor de 19 horas
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?

Respuestas (1)

dpb
dpb hace alrededor de 3 horas
Editada: dpb hace 14 minutos
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.
  1 comentario
dpb
dpb hace alrededor de 2 horas
Editada: dpb hace 4 minutos
I wondered if they were just zipped files -- the file seems to be, but the base content is still not text -- one can see all the header boilerplate text, but not the code so that doesn't work to be able to try to futz on it externally. Not that it would likely work if did, but ...
And, one can export the code to an m-file, but it doesn't have the GUI data and one can't reimport it directly back into appdesigner. And, even though you could add the code in the m-file, when it came to going back you'd again be stuck with not being able to get past the end of the classdef block.
Although I guess if your GUI development was complete so you didn't need to make any further changes to it, then you could forget about appdesigner and just use the m-code by itself -- then you would be able to use the class-related functionality, but it would be essentially a one-way street.

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by