Is it possible to migrate to MATLAB App Designer (.mlapp) using a properly structured .m file?

Hello,
I wonder if it is possible to migrate a properly structured .m file to App Designer. By proper I mean that it is completely okay to be used in App Designer because it was originally exported by App Designer's "Export to .m File" option.
It's actually a copy-past task but the App Designer's code section for the user interface related components is read-only. I need to remark that it is not migrating from GUIDE to App Designer, it is migrating from a .m file which is exported from App Designer, to App Designer's itself.
So, is there a resolution for this case?
I'd appreciate any assistance or guidance.

6 Commenti

I am not an actual user of AppDesigner, so I don't know the answer, but can you explain why you want this?
Sure, I occasionally need to change a part or some parts of the code within AppDesigner. I perform these tasks programatically and in an automated manner. However, this usually requires tons of small works such as finding relevant sections, copy-pasting, checking conformance etc. If I found a method to convert a structured .m script to .mlapp file, that would be great for efficiency.
I understand the need for programmatic control over you code, but I don't really get why you want you program to stay in AppDesigner. I know that could just be me.
The program is actually the source code of an executable which is designed in AppDesigner, I compile it to be a standalone application and share it to be used with MATLAB Runtime. That's why I can't use it as a script (.m) or live script(.mlx) file and it should be in AppDesigner. If it was an .m or .mlx, simple copy-pasting would work but AppDesigner has read-only parts for UI components which is designated by design pane. Please ask any question you have, that's okay.
Just so you are aware: compiling a function to a standalone application for use the MCR is not exclusive to AppDesigner. If ditching that requirement solves your problem, you might want to look into that.
I must have missed that and will be checking if that helps. Thanks!

Accedi per commentare.

Risposte (1)

There is no easy way to import the exported "m" file into MATLAB App Designer. The "mlapp" file is a structure which contains metadata and XML files, whereas the "m" file contains only the code. In order to directly import the app file, the metadata and the XML files would be needed, which are not present in the "m" file.
If you want to convert the “m” file to executable file, you can use MATLAB Compiler to achieve the same instead of App Designer. You can convert the "m" file to executable using the "mcc" function. Please refer to below code to convert the "m" file to executable file:
mcc -m filename.m
You can refer to the attached link to read more about the “mcc” function:
Similarly, you can use the MATLAB Compiler GUI to convert the "m" file to executable.
Hope this helps.

Categorie

Prodotti

Release

R2022a

Richiesto:

il 23 Giu 2023

Risposto:

il 9 Ago 2023

Community Treasure Hunt

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

Start Hunting!

Translated by