How to use app2 to control the buttons of app1 in app designer?

1 Ansicht (letzte 30 Tage)
jie ren
jie ren am 26 Dez. 2020
Beantwortet: Mario Malic am 26 Dez. 2020
The two apps are linked, and then I wrote a lot of things in the buttons in app1. App2 wants to directly control and press the buttons of app1, and then read the global variables. I don't know if there is any implementation method. Thank you

Antworten (1)

Mario Malic
Mario Malic am 26 Dez. 2020
  • Do you run your apps in the same instance of MATLAB?
If yes, set tags, or unique names for your apps in Component Browser, under UIFigure - Identifiers, and get their handles this way:
%% in your script
app1 = get(findall(0, 'Tag', 'AppUIFigure1'), 'RunningAppInstance');
app2 = get(findall(0, 'Tag', 'AppUIFigure2'), 'RunningAppInstance');
This way, you have access to both apps.
If no, I wouldn't know how to find the other running MATLAB instance.
  • What about simplifying your problem into having a single app with two windows?
Note: don't use global variables, it's unnecessary.

Kategorien

Mehr zu Develop uifigure-Based Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by