필터 지우기
필터 지우기

Can I restrict what path an App looks at for functions, when I have two Apps that use different versions of the same named function?

조회 수: 2 (최근 30일)
I have developed a set of 4 Applications in App Designer to do particular structural calculations. In the past I had the 4 Apps accessible from one UIFigure via 4 buttons - each of which ran a separate App (by calling its "_exported" m-file. I have now updated all the Apps but want to package these with the old versions (on a separate tab). However, the old and new versions potentially share functions of the same name, but (slightly) different functuionality. Although I have images of all the functions the last time I compiled the Apps, (2 years ago), if I try to compile old and new versions now, then I will potentially run into problems with the old versions trying to use new versions of functions and vice versa.
I have built a simple application (attached) that acts as a switchyard to call 2 versions of another dummy application. One version calls a file foo.m that mutiplies an input by 2; the other version calls a function foo.m (stored in a different folder) that mutiplies its input by 3. I tried to restrict the path at the point were the Apps were created but that didn't work. I haven't tried to compile anything but figure that if I can't get it to work as a stand-alone, I won't get it to work compiled.
Is there a way to restrict what versions of functions an App looks at when running (and/or when being compiled)?
I could compile all the old apps together (with any new versions of functions hidden) and then do the same for the new apps, but really wanted to just have one version with old and new versions on different tabs. Is this possible?

채택된 답변

Walter Roberson
Walter Roberson 2022년 6월 16일
The MATLAB Path is respected at compile time.
At run time, if you were running interactively, you could adjust the MATLAB path at run-time.
At run time, if you are using compiling, then adjusting the MATLAB path is not recommended.
The mechanisms to control path include:
  • adjusting the MATLAB path
  • using packages. Unfortunately, there is no way to set a top-level package name and have everything else in the package use some kind of relative access to that: every location inside the code that wants to access a package function needs to either import using the package name, or use the full package-name qualified name.
  • defining different classes (which might potentially both derive from the same class)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by