필터 지우기
필터 지우기

How to invoke a matlab.apps.AppBase based class without App Designer?

조회 수: 20 (최근 30일)
Kenneth
Kenneth 2024년 2월 2일
댓글: Kenneth 2024년 2월 6일
My App Designer app takes impossibly long to save (20 to 30 seconds) every time I want to do a test run. So I'm trying a different strategy: once and for all, copy all the code out of the app designer code view and make a .m file of it. Then run that. Unfortunately, this simply defines the class and then exits. It does not create a window or run the class within that window.
Can this work? Is there some way I can make a stub of a main program that invokes my app class in this fashion?

답변 (1개)

Alberto Cuadra Lara
Alberto Cuadra Lara 2024년 2월 2일
Hi Kenneth,
I think that should work. Have you saved the *.m file with the same name as the *.mlapp? Otherwise you should rename classdef accordingly, as well as the name of the construct app function, namely
classdef newAppName < matlab.apps.AppBase
% Your app
% App creation and deletion
methods (Access = public)
% Construct app
function app = newAppName
end
% Delete app
end
end
  댓글 수: 3
Alberto Cuadra Lara
Alberto Cuadra Lara 2024년 2월 3일
Let's consider your mlapp file was oldAppName.mlapp, in that case the class name will be oldAppName, namely
classdef oldAppName < matlab.apps.AppBase
and the constructor line will have the same oldAppName reference.
If you copy-paste your code from AppDesigner to a newAppName.m file, you have to modify the class name and the constructor accordingly, as I indicated in the previous comment.
I hope this help.
Best,
Alberto
Kenneth
Kenneth 2024년 2월 6일
You are still missing my question. Where is the first line of code that gets run when I run this app? Is it the app constructor? I can see where the .mlapp file DEFINES the app class, but what INSTANTIATES it?

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

카테고리

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

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by