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

3 views (last 30 days)
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

Answers (1)

Mario Malic
Mario Malic on 26 Dec 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.

Categories

Find more on Develop uifigure-Based Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!